Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sunshine Reads Incorrect Monitor Index #221

Open
JustPlainGarak opened this issue Jun 22, 2022 · 29 comments
Open

Sunshine Reads Incorrect Monitor Index #221

JustPlainGarak opened this issue Jun 22, 2022 · 29 comments
Labels
os:Linux:Fedora OS is Fedora

Comments

@JustPlainGarak
Copy link

Describe the Bug

When running Sunshine, even though my primary display shows as index 0, if I leave the Monitor Number blank or input index number 0, Sunshine always picks my HDMI connected display, which is not my primary. I have to cycle through index numbers and restart the service until I find the correct monitor even though the index number for my primary DisplayPort connected display still shows as monitor 0 in xrandr.

Expected Behavior

Sunshine should select the monitor at index 0 by default.

Additional Context

I am running 4 connected displays, 1 HDMI and 3 DisplayPort. The index number for my primary display always shows index 0 even though Sunshine picks the HDMI display, which can be any index number from 1-3 in xrandr.

Sunshine Host Operating System and Version

Fedora 36 KDE Plasma

Architecture

x86_64

Sunshine Version

0.14.0

GPU Type

AMD

GPU Model

Radeon RX 6700XT

GPU Driver/Mesa Version

Mesa 23.0.0-git (using gloriousegroll copr repo)

Capture Method (Linux Only)

Not sure, whatever the default for a Fedora/Wayland install would be

@ReenigneArcher ReenigneArcher added the os:Linux:Fedora OS is Fedora label Jun 22, 2022
@ReenigneArcher
Copy link
Member

What is the output of xrandr --listmonitors?

And please paste your config file as well.

@JustPlainGarak
Copy link
Author

JustPlainGarak commented Jun 23, 2022

Hey, thanks for the reply! I will include that info for you now. I took some logs as well (one left at default which picks the wrong monitor and one with the "wrong" monitor index selected, 3, outputting to the correct monitor).

xrandr output

xrandr --listmonitors
Monitors: 4
 0: +*XWAYLAND0 2560/700x1440/400+2560+1080  XWAYLAND0
 1: +XWAYLAND1 2560/600x1440/340+0+1080  XWAYLAND1
 2: +XWAYLAND2 2560/600x1440/340+5120+1080  XWAYLAND2
 3: +XWAYLAND3 1920/600x1080/340+640+0  XWAYLAND3

Config file

cat /usr/local/sunshine/config/sunshine.conf 
sunshine_name = EmpokNor
nv_preset = default
amd_coder = auto
upnp = disabled
gamepad = x360
qp = 22
nv_rc = auto
hevc_mode = 0
dwmflush = enabled
min_log_level = 2
amd_quality = default
origin_web_ui_allowed = lan
vt_software = auto
vt_realtime = enabled
key_rightalt_to_key_win = disabled
origin_pin_allowed = pc
resolutions = [
    352x240,
    480x360,
    858x480,
    1280x720,
    1920x1080,
    2560x1080,
    3440x1440,
    1920x1200,
    3860x2160,
    3840x1600,
    2560x1440
]
nv_coder = auto
fps = [10,30,60,90,120]
vt_coder = auto
amd_rc = auto
output_name = 3

@ReenigneArcher
Copy link
Member

output_name = 3 this is telling it to select this monitor 3: +XWAYLAND3 1920/600x1080/340+640+0 XWAYLAND3

@JustPlainGarak
Copy link
Author

JustPlainGarak commented Jun 23, 2022

output_name = 3 this is telling it to select this monitor 3: +XWAYLAND3 1920/600x1080/340+640+0 XWAYLAND3

Yeah, that is what it's supposed to do, I agree. But when I set output to 3, it selects 0 and streams that screen. Conversely, if I select monitor 0 (or leave the field in the web UI blank not specifying a monitor) Sunshine streams monitor 3, the HDMI connected 1080p monitor.

@Firokat
Copy link

Firokat commented Aug 16, 2022

Can confirm the issue on an Arch host, I have 2 monitors and Sunshine is swapping their indexes.
xrandr --listmonitors shows this:

Monitors: 2
 0: +*DP-0 1920/531x1080/298+0+0  DP-0
 1: +HDMI-0 1920/160x1080/90+1920+0  HDMI-0

By default (index 0), Sunshine streams the HDMI monitor.

@LizardByte-bot
Copy link
Member

This issue is stale because it has been open for 90 days with no activity. Comment or remove the stale label, otherwise this will be closed in 10 days.

@LizardByte-bot
Copy link
Member

This issue was closed because it has been stalled for 10 days with no activity.

@LizardByte-bot LizardByte-bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2022
@maxanier
Copy link

Can confirm that there is something off:

xrandr --list-monitors
 0: +*DP-4 2560/598x1440/336+1080+260  DP-4
 1: +HDMI-0 1080/531x1920/299+0+0  HDMI-0
 2: +DP-0 2560/597x1440/336+3640+260  DP-0

Choosing 0 results in streaming 1, 1 results in monitor 2 and specifying 2 streams monitor 0.

@kodemeister
Copy link
Contributor

I have exactly the same issue with 2 monitors. Selecting monitor 0 in Sunshine actually streams monitor 1 and vice versa.

Monitors: 2
 0: +*DP-1 3840/597x2160/336+0+0  DP-1
 1: +DP-2 3840/597x2160/336+3840+0  DP-2

xrandr reports monitor order as seen by X11, while Sunshine uses KMS instead of X11. Is it possible that KMS and X11 use different monitor order?

@KuleRucket
Copy link
Contributor

It would be nice if the ID was used instead of a number. With a dummy + a desktop monitor that can be on or off, the output number can change.

@kodemeister
Copy link
Contributor

Agree. Using some unique ID would be better than monitor index.

Unfortunately port names like DP-1 or DP-2 also don't seem to be stable. They can change when monitors are plugged on and off. In addition, they can differ in X11 and Wayland sessions.

https://unix.stackexchange.com/questions/584088/how-can-i-get-stable-video-output-names
https://bugs.kde.org/show_bug.cgi?id=385135

Probably the best way would be to use monitor identifiers (serial numbers) from EDID. For instance, they are displayed in KDE Plasma settings. On my system they are:

BenQ PD2700U ETR3K01703SL0
BenQ PD2700U ETR3K01702SL0

@guilty-p01nt3r
Copy link

Do you know if there is any workaround for now?
It's uncomfortable changing the monitor from my smartphone while I'm gaming away from my home pc

If I can be of any help, I'm here with the same bug

  • sunshine 19.1
  • AMD 7900 XT
  • arch 6.2.9-zen1-1-zen
  • mesa 23.0.1-2
  • Wayland 1.21.0-2

@BadKiko
Copy link

BadKiko commented May 31, 2023

Same issue, arch linux host
Monitors: 2
0: +*DisplayPort-0 1920/521x1080/293+0+0 DisplayPort-0
1: +HDMI-A-0 1920/527x1080/296+1920+0 HDMI-A-0
sunshine use hdmi monitor if i set 0 index, but if i set index 1 it use dp-0 :)

@KuleRucket
Copy link
Contributor

I don't think you can guarantee that monitors detected by all capture methods use the index as reported by xrandr --list-monitors. This is just the x11 order.

@KuleRucket
Copy link
Contributor

Also, xrandr --list-monitors only gives you connected monitors but since #1071 the index covers all ports not just connected

@sgtnoodle
Copy link

I encountered this as well. The order change coincided with switching from X11/VAAPI to NVFBC/NVENC. The nvidia based setup's order is inconsistent with xrandr.

I've been having fun battling my streaming setup. My goal is a virtual KVM setup for my work laptop, where it's just a window on my personal workstation. Originally my laptop was set to "discrete graphics" in the BIOS, and sunshine would only do X11 with software encoding despite running the NVIDIA driver. I switched to "hybrid graphics", and then sunshine would do KMS/NVENC on the built-in display. I wanted higher resolution, though, so I got an HDMI EDID dummy plug and attached it to a dock. Sunshine would then only do X11/VAAPI on the external dummy display. Today I just found a driver patch to enable NVFBC, and now NVFBC/NVENC is working on my dummy external display.

As painful as it was to get working, the NVENC experience is buttery smooth with no CPU load.

@sersorrel
Copy link

sersorrel commented Jan 26, 2024

this issue remains. I have monitors in the following configuration:

image

and sunshine reports that they are numbered like this:

[2024:01:26:00:07:38]: Info: Detected monitor 0: DP-1, connected: true
[2024:01:26:00:07:38]: Info: Detected monitor 1: DP-2, connected: false
[2024:01:26:00:07:38]: Info: Detected monitor 2: HDMI-1, connected: true
[2024:01:26:00:07:38]: Info: Detected monitor 3: HDMI-2, connected: true

but this doesn't match the numbers I need to use in the sunshine config at all – there, the mapping is:

  • 0: HDMI-1
  • 1: HDMI-2
  • 2: DP-1

and xrandr --listmonitors produces an entirely different ordering again:

Monitors: 3
 0: +*HDMI-2 2560/597x1440/336+1920+1440  HDMI-2
 1: +DP-1 1920/527x1080/296+0+1440  DP-1
 2: +HDMI-1 2560/597x1440/336+1920+0  HDMI-1

I'm using NixOS 24.05.20240121.612f972 (Uakari) with X11.

@cgutman
Copy link
Collaborator

cgutman commented Jan 26, 2024

@sersorrel The monitor numbers come from different capture subsystems (X11 vs Wayland vs NvFBC vs KMS). The intent is for them to be the same but it is not always possible.

What capture method is being used on your system?

@sersorrel
Copy link

KMS, I think.

@KnoBuddy
Copy link

I have an issue where it only shows 2 monitors connected but there are 3.

The numbers are swapped around, and selecting 0 and 2 give the wrong monitor when connected. (It says that 0 is disconnected in Sunshine GUI, see code below)

And when I select monitor 1, 3, or 4, and connect from moonlight it displays all 3 displays in a zoomed out view. (See screenshot)

Running Ubuntu 22.04 LTS.

Monitors: 3
 0: +*DP-5 1920/598x1080/336+1920+0  DP-5
 1: +DP-1 1920/531x1080/299+3840+0  DP-1
 2: +HDMI-0 1920/1600x1080/900+0+0  HDMI-0
Info: Detecting connected monitors
            Info: Detected monitor 0: DVI-D-0, connected: false
            Info: Detected monitor 1: HDMI-0, connected: true
            Info: Detected monitor 2: DP-0, connected: true
            Info: Detected monitor 3: DP-1, connected: false
            Info: Detected monitor 4: DVI-D-1, connected: false

Screenshot_20240316-121631

@PhiSYS
Copy link

PhiSYS commented Apr 9, 2024

I have a laptop with intel+nvidia with an extra monitor. Using Kubuntu 22.04.
Adapter name: /dev/dri/renderD129
Force NVENC Encoder.

$ xrandr --listmonitors
Monitors: 2
 0: +*eDP-1 1920/336x1200/210+0+0  eDP-1
 1: +DP-3 1920/480x1080/270+1920+0  DP-3

In Shunsine GUI:

Info: Detecting connected monitors
Info: Detected monitor 0: DVI-D-0, connected: false
Info: Detected monitor 1: HDMI-0, connected: true
Info: Detected monitor 2: DP-0, connected: true
Info: Detected monitor 3: DP-1, connected: false
Info: Detected monitor 4: DVI-D-1, connected: false

I can only see one screen, always the main one (that's the laptop panel) if I set the "Monitor number" field to empty or 0.

I was trying to cast the secondary screen only, but entering other value in the "Monitor number" field (1,2...) results in casting all displays in a zoomed out view, just like in @KnoBuddy comment.

@PhiSYS
Copy link

PhiSYS commented Apr 9, 2024

Regarding to my previous comment, I kept incrementing the index just for testing, and the second screen (only) was casted using index 4, which makes no sense to me.

@cheungyau2022
Copy link

I am having the exact same issue.

[2024:06:07:11:51:17]: Info: Detecting monitors
[2024:06:07:11:51:18]: Info: Detected monitor 0: DP-0, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 1: DP-1, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 2: DP-2, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 3: DP-3, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 4: HDMI-0, connected: true
[2024:06:07:11:51:18]: Info: Detected monitor 5: DP-4, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 6: DP-5, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 7: HDMI-1, connected: true
[2024:06:07:11:51:18]: Info: Detected monitor 8: DP-6, connected: false
[2024:06:07:11:51:18]: Info: Detected monitor 9: DP-7, connected: false

According to Sunshine I need to stream monitor 7, but if I set it to 7 in configuration page Sunshine wouldn't start at all.
Now it's only streaming the whole virtual desktop including both of my monitor's image. It's driving me crazy.
I tried number 0, 1, or 2 and none of them worked.

@sorin255
Copy link

Yeah I just started getting this too.

I have two monitors, on 1 and 2, preferring 1. They both show as connected:true

If I set it to 0 it will stream (but just a blank screen + audio)

If I set it to anything other than monitor 0 I get an error that monitor wasn't detected.

@tabiznet
Copy link

tabiznet commented Jul 6, 2024

I have an issue where it only shows 2 monitors connected but there are 3.

The numbers are swapped around, and selecting 0 and 2 give the wrong monitor when connected. (It says that 0 is disconnected in Sunshine GUI, see code below)

And when I select monitor 1, 3, or 4, and connect from moonlight it displays all 3 displays in a zoomed out view. (See screenshot)

Running Ubuntu 22.04 LTS.

Monitors: 3
 0: +*DP-5 1920/598x1080/336+1920+0  DP-5
 1: +DP-1 1920/531x1080/299+3840+0  DP-1
 2: +HDMI-0 1920/1600x1080/900+0+0  HDMI-0
Info: Detecting connected monitors
            Info: Detected monitor 0: DVI-D-0, connected: false
            Info: Detected monitor 1: HDMI-0, connected: true
            Info: Detected monitor 2: DP-0, connected: true
            Info: Detected monitor 3: DP-1, connected: false
            Info: Detected monitor 4: DVI-D-1, connected: false

Screenshot_20240316-121631

I'm having this exact same issue. I just want sunshine to use the 2nd display only but it shows them all in a zoomed out view. Have you found a workaround?

Edit: Selecting monitor 0 enables my second (HDMI) display.. weird now I just gotta figure out how to match the resolution

Info: Detecting connected monitors
              Info: Detected monitor 0: DVI-D-0, connected: false
              Info: Detected monitor 1: HDMI-0, connected: true
              Info: Detected monitor 2: DP-0, connected: true
              Info: Detected monitor 3: DP-1, connected: false
              Info: Detected monitor 4: DVI-D-1, connected: false

@Lebbitheplow
Copy link

I have an issue where it only shows 2 monitors connected but there are 3.

The numbers are swapped around, and selecting 0 and 2 give the wrong monitor when connected. (It says that 0 is disconnected in Sunshine GUI, see code below)

And when I select monitor 1, 3, or 4, and connect from moonlight it displays all 3 displays in a zoomed out view. (See screenshot)

Running Ubuntu 22.04 LTS.

Monitors: 3
 0: +*DP-5 1920/598x1080/336+1920+0  DP-5
 1: +DP-1 1920/531x1080/299+3840+0  DP-1
 2: +HDMI-0 1920/1600x1080/900+0+0  HDMI-0
Info: Detecting connected monitors
            Info: Detected monitor 0: DVI-D-0, connected: false
            Info: Detected monitor 1: HDMI-0, connected: true
            Info: Detected monitor 2: DP-0, connected: true
            Info: Detected monitor 3: DP-1, connected: false
            Info: Detected monitor 4: DVI-D-1, connected: false

Screenshot_20240316-121631

Same issue here, i have two DP monitors but only one is detected. POP_OS 22.04
Info: Detecting displays
Info: Detected display: DVI-D-0 (id: 0) connected: false
Info: Detected display: HDMI-0 (id: 1) connected: true
Info: Detected display: DP-0 (id: 2) connected: true
Info: Detected display: DP-1 (id: 3) connected: false
Info: Detected display: DVI-D-1 (id: 4) connected: false

@gschintgen
Copy link
Contributor

Same issue here, i have two DP monitors but only one is detected. POP_OS 22.04

Info: Detecting displays
Info: Detected display: DVI-D-0 (id: 0) connected: false 
Info: Detected display: HDMI-0 (id: 1) connected: true 
Info: Detected display: DP-0 (id: 2) connected: true 
Info: Detected display: DP-1 (id: 3) connected: false 
Info: Detected display: DVI-D-1 (id: 4) connected: false

That text is only a (misleading) example. Check the log file for the actual output.

(There is a PR to improve the text. It is indeed confusing.)

@LizardByte-bot
Copy link
Member

It seems this issue hasn't had any activity in the past 90 days. If it's still something you'd like addressed, please let us know by leaving a comment. Otherwise, to help keep our backlog tidy, we'll be closing this issue in 10 days. Thanks!

@Trezamere
Copy link

Still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:Linux:Fedora OS is Fedora
Projects
None yet
Development

No branches or pull requests