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

Add new API to modify display devices for Windows #2582

Closed
wants to merge 1 commit into from

Conversation

FrogTheFrog
Copy link
Collaborator

This is a continuation of the #2032 PR after a rebase fiasco...

Description

New changes allow for Sunshine to control display devices on Windows, such as:

  • changing display mode (resolution and refresh rate);
  • activating/deactivating displays;
  • enabling/disabling HDR;

It also moves away from the \\.\DISPLAY1-like configurable output names to proper that are pretty persistent (IDs changed a little after I reinstalled my GPU drivers, after DDU).

The applied changes are saved additionally saved to a file in case the PC dies or something so that Sunshine can undo the changes once it is started again.

Screenshot

Example of the new options exposed to the user:

image
image
image
image
image

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

Known issues (all resolved)

  • IDD HDR driver displays high-contrast colors when the display is activated and was inactive before. Seems to be a driver issue, since it does not happen with HDR dongle. A workaround would be to reset all the HDR states to off and then on again, but I don't think we should implement this workaround for this.
  • Sound fails to reset back to whatever was used before after the stream ends if a new display (without the same sink) was the only active display.

Copy link

codecov bot commented May 26, 2024

Codecov Report

Attention: Patch coverage is 1.10529% with 1700 lines in your changes missing coverage. Please review.

Project coverage is 8.80%. Comparing base (f4dda21) to head (b6f8573).
Report is 116 commits behind head on master.

Files with missing lines Patch % Lines
.../platform/windows/display_device/windows_utils.cpp 0.00% 310 Missing ⚠️
src/platform/windows/display_device/settings.cpp 0.00% 268 Missing ⚠️
src/display_device/parsed_config.cpp 0.39% 176 Missing and 75 partials ⚠️
...latform/windows/display_device/device_topology.cpp 0.00% 188 Missing ⚠️
...c/platform/windows/display_device/device_modes.cpp 0.00% 143 Missing ⚠️
src/display_device/session.cpp 1.06% 68 Missing and 25 partials ⚠️
...tform/windows/display_device/settings_topology.cpp 0.00% 88 Missing ⚠️
src/display_device/to_string.cpp 0.00% 48 Missing and 39 partials ⚠️
...tform/windows/display_device/general_functions.cpp 2.98% 64 Missing and 1 partial ⚠️
...tform/windows/display_device/device_hdr_states.cpp 0.00% 44 Missing ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #2582      +/-   ##
=========================================
- Coverage    9.57%   8.80%   -0.77%     
=========================================
  Files          97     115      +18     
  Lines       17586   19289    +1703     
  Branches     8336    9275     +939     
=========================================
+ Hits         1683    1699      +16     
- Misses      13174   14529    +1355     
- Partials     2729    3061     +332     
Flag Coverage Δ
Linux 6.72% <1.33%> (-0.23%) ⬇️
Windows 4.54% <0.49%> (-0.54%) ⬇️
macOS-12 9.80% <1.89%> (-0.49%) ⬇️
macOS-13 9.72% <1.89%> (-0.48%) ⬇️
macOS-14 10.01% <1.89%> (-0.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/audio.h 50.00% <100.00%> (+50.00%) ⬆️
src/audio.cpp 29.07% <75.00%> (+0.50%) ⬆️
src/config.h 0.00% <0.00%> (ø)
src/display_device/parsed_config.h 0.00% <0.00%> (ø)
src/display_device/session.h 0.00% <0.00%> (ø)
src/process.cpp 1.34% <0.00%> (-0.01%) ⬇️
src/platform/windows/display_base.cpp 12.92% <0.00%> (-0.03%) ⬇️
...latform/windows/display_device/settings_topology.h 0.00% <0.00%> (ø)
...rc/platform/windows/display_device/windows_utils.h 0.00% <0.00%> (ø)
src/video.cpp 25.25% <50.00%> (-0.05%) ⬇️
... and 18 more

... and 19 files with indirect coverage changes

@ReenigneArcher
Copy link
Member

Due to recent changes to the docs, all the doc changes to ./docs/source/source* can be dropped from this PR.

@FrogTheFrog FrogTheFrog force-pushed the master branch 3 times, most recently from b81c566 to e31f0ae Compare June 25, 2024 19:31
@mirh
Copy link

mirh commented Jun 28, 2024

Very little note while I was going through my comments.. But HDR control may require a "extra" mode to plug into nvapi (which somehow I just noticed you already pulled in as a dependency?) for games that do their magic through it.

@FrogTheFrog
Copy link
Collaborator Author

Very little note while I was going through my comments.. But HDR control may require a "extra" mode to plug into nvapi (which somehow I just noticed you already pulled in as a dependency?) for games that do their magic through it.

For now this PR will focus on interacting with Windows API only and enabling "global" HDR setting only.

@bradleycundari
Copy link

bradleycundari commented Jul 3, 2024

I can't wait for this PR to get merged, I can't stress how amazing this is, thank you! If I were to take this, build it, install, would everything work as expected aside from a bug here or there? Assuming this would be the case but just want to verify since I'm not involved in this project.

@moi952
Copy link

moi952 commented Jul 3, 2024

I can't wait for this PR to get merged, I can't stress how amazing this is, thank you! If I were to take this, build it, install, would everything work as expected aside from a bug here or there? Assuming this would be the case but just want to verify since I'm not involved in this project.

I play almost every day with this dev on Windows 11 and I have no problems. You can download it with your eyes closed

@FrogTheFrog
Copy link
Collaborator Author

@bradleycundari as moi952 just mentioned, you can download Github artifacts. However, they are needlessly hidden for someone without some previous knowledge:
image
image
image

@mirh

This comment was marked as off-topic.

@FrogTheFrog
Copy link
Collaborator Author

Please don't hijack this PR for off-topic discussions.

@kanjieater
Copy link

I hope it's ok if I give some feedback after using this branch for a bit. It works very well, but I found that if I change my monitor configuration it can enter into a state that's unrecoverable, so I have to Win+P to get my monitor back, then resetup my displays. I was hoping on failure it could still restore my present monitors, instead of failing the all the monitors restore if one is no longer connected.

I think i may have to restart my sunshine server every time my monitor configuration changes so it can snapshot the current state, when it might be more convenient to just restore to the state before the current session, for all monitors that you can still ID as available.
image

[2024:07:21:14:56:32]: Info: Sunshine version: 0.0.0.16febac0483d3107c266e6e84e0891b1126f8de9
[2024:07:21:14:56:32]: Info: Available display devices: 
DEVICE ID: {11374da5-3326-592c-a729-84763d7ee42a}
DISPLAY NAME: \\.\DISPLAY4
FRIENDLY NAME: BenQ GW2765
DEVICE STATE: PRIMARY
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {5ae0f01c-ca36-56ca-80bc-d6764ad5ef86}
DISPLAY NAME: \\.\DISPLAY1
FRIENDLY NAME: BenQ GW2765
DEVICE STATE: ACTIVE
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {6f6b3d17-756d-5f20-96b0-d83d19ada497}
DISPLAY NAME: \\.\DISPLAY3
FRIENDLY NAME: HMD-A440
DEVICE STATE: ACTIVE
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {d05cd62a-e131-5bd8-8f21-b743818ba67d}
DISPLAY NAME: \\.\DISPLAY2
FRIENDLY NAME: LG ULTRAGEAR+
DEVICE STATE: ACTIVE
HDR STATE: DISABLED
-----------------------
DEVICE ID: {e4e51468-35d5-5833-8b43-41ab3f6abc91}
DISPLAY NAME: NOT AVAILABLE
FRIENDLY NAME: IDD HDR
DEVICE STATE: INACTIVE
HDR STATE: UNKNOWN
[2024:07:21:14:56:32]: Warning: Reverting display settings will fail - retrying later...
[2024:07:21:14:56:32]: Info: nvprefs: Opened undo file from previous improper termination
[2024:07:21:14:56:32]: Info: nvprefs: Restored OGL_CPL_PREFER_DXPRESENT for base profile
[2024:07:21:14:56:32]: Info: nvprefs: Restored global profile settings from undo file - deleting the file
[2024:07:21:14:56:32]: Info: nvprefs: No need to modify application profile settings
[2024:07:21:14:56:32]: Info: nvprefs: Changed OGL_CPL_PREFER_DXPRESENT to OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED for base profile
[2024:07:21:14:56:33]: Info: Compiling shaders...
[2024:07:21:14:56:33]: Info: Compiled shaders
[2024:07:21:14:56:33]: Warning: Gamepad x360 is disabled due to gamepads.vigem-not-available
[2024:07:21:14:56:33]: Warning: Gamepad ds4 is disabled due to gamepads.vigem-not-available
[2024:07:21:14:56:33]: Warning: No gamepad input is available
[2024:07:21:14:56:33]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:07:21:14:56:33]: Info: Trying encoder [nvenc]
[2024:07:21:14:56:34]: Info: ddprobe.exe [1] [] returned: 0x00000000
[2024:07:21:14:56:34]: Info: Set GPU preference: 1
[2024:07:21:14:56:34]: Info: 
Device Description : NVIDIA GeForce RTX 4070 Ti
Device Vendor ID   : 0x000010DE
Device Device ID   : 0x00002782
Device Video Mem   : 11996 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 32653 MiB
Feature Level      : 0x0000B100
Capture size       : 1024x768
Offset             : 0x595
Virtual Desktop    : 6464x2560
[2024:07:21:14:56:34]: Info: Active GPU has HAGS enabled
[2024:07:21:14:56:34]: Info: Using realtime GPU priority
[2024:07:21:14:56:34]: Info: 
Colorspace         : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color     : 8
Red Primary        : [0.639648,0.330078]
Green Primary      : [0.299805,0.599609]
Blue Primary       : [0.149414,0.0595703]
White Point        : [0.3125,0.329102]
Min Luminance      : 0.5 nits
Max Luminance      : 270 nits
Max Full Luminance : 270 nits
[2024:07:21:14:56:34]: Info: Desktop resolution [1024x768]
[2024:07:21:14:56:34]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2024:07:21:14:56:34]: Info: Display refresh rate [60.004Hz]
[2024:07:21:14:56:34]: Info: Requested frame rate [60fps]
[2024:07:21:14:56:34]: Info: SDR color coding [Rec. 601]
[2024:07:21:14:56:34]: Info: Color depth: 8-bit
[2024:07:21:14:56:34]: Info: Color range: [JPEG]
[2024:07:21:14:56:34]: Info: System tray created
[2024:07:21:14:56:34]: Info: NvEnc: created encoder P4 two-pass rfi
[2024:07:21:14:56:34]: Info: SDR color coding [Rec. 601]
[2024:07:21:14:56:34]: Info: Color depth: 8-bit
[2024:07:21:14:56:34]: Info: Color range: [JPEG]
[2024:07:21:14:56:35]: Info: NvEnc: created encoder P4 two-pass rfi
[2024:07:21:14:56:35]: Info: SDR color coding [Rec. 601]
[2024:07:21:14:56:35]: Info: Color depth: 8-bit
[2024:07:21:14:56:35]: Info: Color range: [JPEG]
[2024:07:21:14:56:35]: Info: NvEnc: created encoder P4 two-pass rfi
[2024:07:21:14:56:35]: Info: 
Device Description : NVIDIA GeForce RTX 4070 Ti
Device Vendor ID   : 0x000010DE
Device Device ID   : 0x00002782
Device Video Mem   : 11996 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 32653 MiB
Feature Level      : 0x0000B100
Capture size       : 1024x768
Offset             : 0x595
Virtual Desktop    : 6464x2560
[2024:07:21:14:56:35]: Info: Active GPU has HAGS enabled
[2024:07:21:14:56:35]: Info: Using realtime GPU priority
[2024:07:21:14:56:35]: Info: 
Colorspace         : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color     : 8
Red Primary        : [0.639648,0.330078]
Green Primary      : [0.299805,0.599609]
Blue Primary       : [0.149414,0.0595703]
White Point        : [0.3125,0.329102]
Min Luminance      : 0.5 nits
Max Luminance      : 270 nits
Max Full Luminance : 270 nits
[2024:07:21:14:56:35]: Info: Desktop resolution [1024x768]
[2024:07:21:14:56:35]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2024:07:21:14:56:35]: Info: Display refresh rate [60.004Hz]
[2024:07:21:14:56:35]: Info: Requested frame rate [60fps]
[2024:07:21:14:56:35]: Info: SDR color coding [Rec. 709]
[2024:07:21:14:56:35]: Info: Color depth: 10-bit
[2024:07:21:14:56:35]: Info: Color range: [JPEG]
[2024:07:21:14:56:35]: Info: NvEnc: created encoder P4 10-bit two-pass rfi
[2024:07:21:14:56:35]: Info: SDR color coding [Rec. 709]
[2024:07:21:14:56:35]: Info: Color depth: 10-bit
[2024:07:21:14:56:35]: Info: Color range: [JPEG]
[2024:07:21:14:56:35]: Info: NvEnc: created encoder P4 10-bit two-pass rfi
[2024:07:21:14:56:35]: Info: 
[2024:07:21:14:56:35]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:07:21:14:56:35]: Info: 
[2024:07:21:14:56:35]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2024:07:21:14:56:35]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
[2024:07:21:14:56:35]: Info: Found AV1 encoder: av1_nvenc [nvenc]
[2024:07:21:14:56:35]: Info: Configuration UI available at [https://localhost:47990]
[2024:07:21:14:56:36]: Info: Registered Sunshine mDNS service
[2024:07:21:14:56:37]: Info: Loading persistent display device settings.
[2024:07:21:18:50:48]: Info: Applying configuration to the display device.
[2024:07:21:18:50:49]: Info: Available display devices: 
DEVICE ID: {11374da5-3326-592c-a729-84763d7ee42a}
DISPLAY NAME: \\.\DISPLAY1
FRIENDLY NAME: BenQ GW2765
DEVICE STATE: PRIMARY
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {5ae0f01c-ca36-56ca-80bc-d6764ad5ef86}
DISPLAY NAME: \\.\DISPLAY2
FRIENDLY NAME: BenQ GW2765
DEVICE STATE: ACTIVE
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {6f6b3d17-756d-5f20-96b0-d83d19ada497}
DISPLAY NAME: \\.\DISPLAY4
FRIENDLY NAME: HMD-A440
DEVICE STATE: ACTIVE
HDR STATE: UNKNOWN
-----------------------
DEVICE ID: {d05cd62a-e131-5bd8-8f21-b743818ba67d}
DISPLAY NAME: \\.\DISPLAY3
FRIENDLY NAME: LG ULTRAGEAR+
DEVICE STATE: ACTIVE
HDR STATE: DISABLED
-----------------------
DEVICE ID: {e4e51468-35d5-5833-8b43-41ab3f6abc91}
DISPLAY NAME: NOT AVAILABLE
FRIENDLY NAME: IDD HDR
DEVICE STATE: INACTIVE
HDR STATE: UNKNOWN
[2024:07:21:18:50:49]: Info: Changing display topology to: 
[
    [
        {e4e51468-35d5-5833-8b43-41ab3f6abc91}
    ]
]
[2024:07:21:18:50:49]: Info: Changing display modes to: 
{e4e51468-35d5-5833-8b43-41ab3f6abc91} -> 3840x2160x60
[2024:07:21:18:50:49]: Info: Changing hdr states to: 
{e4e51468-35d5-5833-8b43-41ab3f6abc91} -> ENABLED
[2024:07:21:18:50:51]: Info: Display device configuration applied.
[2024:07:21:18:50:51]: Info: Encoder reenumeration is required
[2024:07:21:18:50:51]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:07:21:18:50:51]: Info: Trying encoder [nvenc]
[2024:07:21:18:50:51]: Info: 
...
[2024:07:22:05:59:41]: Info: Changing display topology back to: 
[
    [
        {11374da5-3326-592c-a729-84763d7ee42a}
    ],
    [
        {5ae0f01c-ca36-56ca-80bc-d6764ad5ef86}
    ],
    [
        {d05cd62a-e131-5bd8-8f21-b743818ba67d}
    ],
    [
        {6f6b3d17-756d-5f20-96b0-d83d19ada497}
    ]
]
[2024:07:22:05:59:41]: Error: Device {6f6b3d17-756d-5f20-96b0-d83d19ada497} does not exist in the available topology data!
[2024:07:22:05:59:41]: Error: Failed to switch back to the initial topology!
[2024:07:22:05:59:41]: Error: Failed to revert display device settings!
[2024:07:22:05:59:46]: Info: Reverting display device settings.

@FrogTheFrog
Copy link
Collaborator Author

@kanjieater Since I do not know which monitor is gone, I cannot just stop trying to restore the initial configuration.

However, what about an intermediate phase?
Like this:

  1. Initial displays: [[A], [B], [C], [D]]
  2. Activated display: [[E]]
  3. ...
  4. Trying to restore: [[A], [B], [C], [D]], but missing [A] and [B].
  5. Restore [[C], [D]]
  6. Keep trying to restore [[A], [B], [C], [D]]
  7. User has to click the "Reset Persistence" in Sunshine to stop

@ns6089
Copy link
Contributor

ns6089 commented Jul 22, 2024

@FrogTheFrog sorry for interfering, but do we even want to mess with manual restoration of multiple displays?
Just switch to "pc screen only" topology with whatever display we want. Then switch the topology back to "extend" on the way out, windows can figure out what and how it wants to restore.

@kanjieater
Copy link

@kanjieater Since I do not know which monitor is gone, I cannot just stop trying to restore the initial configuration.

However, what about an intermediate phase? Like this:

  1. Initial displays: [[A], [B], [C], [D]]
  2. Activated display: [[E]]
  3. ...
  4. Trying to restore: [[A], [B], [C], [D]], but missing [A] and [B].
  5. Restore [[C], [D]]
  6. Keep trying to restore [[A], [B], [C], [D]]
  7. User has to click the "Reset Persistence" in Sunshine to stop
    Hmm, I'm not sure what the intermediate phase would be there (at 3?).
    But, 1,2,4, and finally 5 would be the state I would expect in this situation.

Originally i was thinking:
If you checked again for what monitors are available before trying to restore, you could detect that one was missing.
Or, alternatively, on failure of restore, restore monitors individually/iteratively.

@FrogTheFrog
Copy link
Collaborator Author

FrogTheFrog commented Jul 22, 2024

@FrogTheFrog sorry for interfering, but do we even want to mess with manual restoration of multiple displays? Just switch to "pc screen only" topology with whatever display we want. Then switch the topology back to "extend" on the way out, windows can figure out what and how it wants to restore.

Well, I have multiple displays that are mostly always inactive. I do not want them to be restored when we "extend" it on the way out. Also, what if the extension is incomplete and uses currently enabled devices OR fails (because not all devices are available, for example), then we are in the same stupid situation where "sleeping" displays would have to be restored manually. Thus, I chose to at least keep trying.

@FrogTheFrog
Copy link
Collaborator Author

@kanjieater Since I do not know which monitor is gone, I cannot just stop trying to restore the initial configuration.
However, what about an intermediate phase? Like this:

  1. Initial displays: [[A], [B], [C], [D]]
  2. Activated display: [[E]]
  3. ...
  4. Trying to restore: [[A], [B], [C], [D]], but missing [A] and [B].
  5. Restore [[C], [D]]
  6. Keep trying to restore [[A], [B], [C], [D]]
  7. User has to click the "Reset Persistence" in Sunshine to stop
    Hmm, I'm not sure what the intermediate phase would be there (at 3?).
    But, 1,2,4, and finally 5 would be the state I would expect in this situation.

Originally i was thinking: If you checked again for what monitors are available before trying to restore, you could detect that one was missing. Or, alternatively, on failure of restore, restore monitors individually/iteratively.

The problem is sleeping displays - we cannot differentiate between disconnected ones (physically) and the ones that are off. So, a simple user would end up with a monitor that is permanently off since it could not be restored.

As for what you have suggested, that's what I'll be trying to do - restore as much as possible, but still keep trying to restore until either used acknowledges that it's time to stop or we succeed.

@ns6089
Copy link
Contributor

ns6089 commented Jul 22, 2024

Well, I have multiple displays that are mostly always inactive. I do not want them to we restored when we "extend" it on the way out.

Windows stores display configurations (resolutions and placement on the virtual desktop) on the per monitor set per topology basis. If you have any monitor disabled in one topology, switching to another topology and back will restore that too. That's why it will also resolve the newly mentioned issue, windows stores separate configurations for both [[A], [B], [C], [D]] and [[C], [D]] anyway.

@FrogTheFrog
Copy link
Collaborator Author

Well, I have multiple displays that are mostly always inactive. I do not want them to we restored when we "extend" it on the way out.

Windows stores display configurations (resolutions and placement on the virtual desktop) on the per monitor set per topology basis. If you have any monitor disabled in one topology, switching to another topology and back will restore that too. That's why it will also resolve the newly mentioned issue, windows stores separate configurations for both [[A], [B], [C], [D]] and [[C], [D]] anyway.

We have talking about this in private and for now, we stick to the current, but a little improved approach. Future changes/adjustments will be possible once the PRs are merged.

@moi952
Copy link

moi952 commented Jul 22, 2024

Well, I have multiple displays that are mostly always inactive. I do not want them to we restored when we "extend" it on the way out.

Windows stores display configurations (resolutions and placement on the virtual desktop) on the per monitor set per topology basis. If you have any monitor disabled in one topology, switching to another topology and back will restore that too. That's why it will also resolve the newly mentioned issue, windows stores separate configurations for both [[A], [B], [C], [D]] and [[C], [D]] anyway.

We have talking about this in private and for now, we stick to the current, but a little improved approach. Future changes/adjustments will be possible once the PRs are merged.

Do you know when you will have time to finish and when it will be released?

@ns6089
Copy link
Contributor

ns6089 commented Jul 22, 2024

Do you know when you will have time to finish and when it will be released?

When it's done. Please don't manipulate people into giving deadlines, since they're all unpaid volunteers. Thank you.

@moi952
Copy link

moi952 commented Jul 22, 2024

Do you know when you will have time to finish and when it will be released?

When it's done. Please don't manipulate people into giving deadlines, since they're all unpaid volunteers. Thank you.

I'm not manipulating anyone, I'm just asking the question to know when it will be finished because that also allows us to have the latest developments.
I use your version of sunshine because it really simplifies things, it's great.
I know you do this voluntarily and I thank you for it.

@ns6089
Copy link
Contributor

ns6089 commented Jul 22, 2024

I'm not saying you're doing it intentionally, god forbid. But it's still emotional manipulation, the person will naturally try to give to the closest reasonable date possible, then feel bad if they will be failing to meet it for whatever reason. Extra stress with no gain for all parties involved.

@FrogTheFrog
Copy link
Collaborator Author

@kanjieater Since I do not know which monitor is gone, I cannot just stop trying to restore the initial configuration.
However, what about an intermediate phase? Like this:

  1. Initial displays: [[A], [B], [C], [D]]
  2. Activated display: [[E]]
  3. ...
  4. Trying to restore: [[A], [B], [C], [D]], but missing [A] and [B].
  5. Restore [[C], [D]]
  6. Keep trying to restore [[A], [B], [C], [D]]
  7. User has to click the "Reset Persistence" in Sunshine to stop
    Hmm, I'm not sure what the intermediate phase would be there (at 3?).
    But, 1,2,4, and finally 5 would be the state I would expect in this situation.

Originally i was thinking: If you checked again for what monitors are available before trying to restore, you could detect that one was missing. Or, alternatively, on failure of restore, restore monitors individually/iteratively.

Please try windows build from:
https://github.com/FrogTheFrog/Sunshine/actions/runs/10043062539?pr=1

The non-existent displays will not block partially reverting active displays. But it will still try to do it every 5 seconds and as I've said before, you need to tell Sunshine to stop if you're happy with current displays.

Note that this build is based on new stuff - you need to re-enable options in Sunshine and there is no resolution/refresh rate remapping yet

@kanjieater
Copy link

I've been using the update as you recommended @FrogTheFrog . It did fix all of my issues, just wanted to confirm that - thanks for updating & sharing

@brine0m
Copy link

brine0m commented Aug 5, 2024

Random query for this, in the inital PR @FrogTheFrog states that the list of available monitors is outputted as part of Sunshines startup, could this list just be piped into a selection box in the UI for the user to select from instead of hunting through logs etc?

This would create a better user experience and also likely help to reduce user error by putting the wrong value in.

@FrogTheFrog
Copy link
Collaborator Author

Random query for this, in the inital PR @FrogTheFrog states that the list of available monitors is outputted as part of Sunshines startup, could this list just be piped into a selection box in the UI for the user to select from instead of hunting through logs etc?

This would create a better user experience and also likely help to reduce user error by putting the wrong value in.

Someone was already working on it little by little, however for this PR it's out of scope

@sofmeright

This comment was marked as off-topic.

@ReenigneArcher
Copy link
Member

@sofmeright thanks for sharing. It's a bit out of scope of this PR, which will use https://github.com/LizardByte/libdisplaydevice ... but I can add your tool to awesome-sunshine -> LizardByte/awesome-sunshine#13

@moi952
Copy link

moi952 commented Oct 8, 2024

Hi,
I have a problem since an update and maybe since my migration from nvidia (rtx4070) to AMD (7900xt).

It never switches back to the right screen when the stream cuts out, but I did anything and installed a version on your repo https://github.com/FrogTheFrog/Sunshine/actions

I installed the latest, the stream freezes in 10 seconds, so I switched back to the version of this MR, and it no longer wants to switch to the specified screen, the logs (attached) indicate:

[2024:10:08:11:02:54]: Info: Changing display modes to:
{526102e6-465d-522e-a135-6445e888e8d7} -> 3440x1440x140
[2024:10:08:11:02:54]: Info: Failed to change display modes using Windows recommended modes, trying to set modes more strictly!
[2024:10:08:11:02:54]: Error: [code: 1610, message: The configuration data for this product is corrupted. Contact your technical support] failed to set display mode!
[2024:10:08:11:02:54]: Error: Failed to set display mode(-s) completely!
[2024:10:08:11:02:54]: Error: Failed to configure display:
Failed to set new display modes (resolution + refresh rate)
[2024:10:08:11:02:54]: Info: Reverting display device settings.

If you have time to help me with all the work you have that would be great, otherwise I will wait for the release in production.

Thanks for your work

sunshine.log

@FrogTheFrog
Copy link
Collaborator Author

FrogTheFrog commented Oct 8, 2024

Hi, I have a problem since an update and maybe since my migration from nvidia (rtx4070) to AMD (7900xt).

It never switches back to the right screen when the stream cuts out, but I did anything and installed a version on your repo https://github.com/FrogTheFrog/Sunshine/actions

I installed the latest, the stream freezes in 10 seconds, so I switched back to the version of this MR, and it no longer wants to switch to the specified screen, the logs (attached) indicate:

[2024:10:08:11:02:54]: Info: Changing display modes to: {526102e6-465d-522e-a135-6445e888e8d7} -> 3440x1440x140 [2024:10:08:11:02:54]: Info: Failed to change display modes using Windows recommended modes, trying to set modes more strictly! [2024:10:08:11:02:54]: Error: [code: 1610, message: The configuration data for this product is corrupted. Contact your technical support] failed to set display mode! [2024:10:08:11:02:54]: Error: Failed to set display mode(-s) completely! [2024:10:08:11:02:54]: Error: Failed to configure display: Failed to set new display modes (resolution + refresh rate) [2024:10:08:11:02:54]: Info: Reverting display device settings.

If you have time to help me with all the work you have that would be great, otherwise I will wait for the release in production.

Thanks for your work

sunshine.log

Please try a build from this PR:
FrogTheFrog#2

Be aware that you will need to re-do the configuration as I have moved some config stuff around.
Also let's more discussion to that PR if you have further questions.

@moi952
Copy link

moi952 commented Oct 8, 2024

Hi, I have a problem since an update and maybe since my migration from nvidia (rtx4070) to AMD (7900xt).
It never switches back to the right screen when the stream cuts out, but I did anything and installed a version on your repo https://github.com/FrogTheFrog/Sunshine/actions
I installed the latest, the stream freezes in 10 seconds, so I switched back to the version of this MR, and it no longer wants to switch to the specified screen, the logs (attached) indicate:
[2024:10:08:11:02:54]: Info: Changing display modes to: {526102e6-465d-522e-a135-6445e888e8d7} -> 3440x1440x140 [2024:10:08:11:02:54]: Info: Failed to change display modes using Windows recommended modes, trying to set modes more strictly! [2024:10:08:11:02:54]: Error: [code: 1610, message: The configuration data for this product is corrupted. Contact your technical support] failed to set display mode! [2024:10:08:11:02:54]: Error: Failed to set display mode(-s) completely! [2024:10:08:11:02:54]: Error: Failed to configure display: Failed to set new display modes (resolution + refresh rate) [2024:10:08:11:02:54]: Info: Reverting display device settings.
If you have time to help me with all the work you have that would be great, otherwise I will wait for the release in production.
Thanks for your work
sunshine.log

Please try a build from this PR: FrogTheFrog#2

Be aware that you will need to re-do the configuration as I have moved some config stuff around. Also let's more discussion to that PR if you have further questions.

Thanks for your super fast response.

I saved the configuration, I saw that the part that allows to match the resolutions / frame rate was moved so I put back the frame rate matching, moreover it could be interesting for the HDMI dummies to have a maching "if greater than 60 set to the client's frame rate", 60 being a value that can be configured, it avoids doing 90 => 60, 120 => 60, 144 => 60.

It does not switch to the specified screen, except that I do not have the impression of having an error in the logs.

And I have freezes after 10 seconds, then it comes back 10 or 20 seconds later and so on.

I specify that I am on AMD drivers 24.9.1.

Sorry for the inconvenience, maybe it can help to debug.

I'll give you my configuration too. (j'ai du la transformer en .txt car le .json ne passe pas dans github)

Thanks

sunshine.log

sunshine.txt

@FrogTheFrog
Copy link
Collaborator Author

You have an empty remapping entry in the config, please delete this empty entry.

Also lets move the discussion to that othe PR please.

@comsyspro
Copy link

comsyspro commented Oct 12, 2024

When will this #2582 be merged into the master branch? Will that replace the old \.\DISPLAY1 output_name completely or is it compatible with both device id and display id? I also fetched it git fetch origin pull/2582/head:pr-2582 git checkout pr-2582 and compiled it. The compilation had some errors at the end but I could build the zip package. Could you also develop a tool like dxgi-info.exe which will print out all display devices with their device id and display id?

@FrogTheFrog
Copy link
Collaborator Author

When will this #2582 be merged into the master branch? Will that replace the old .\DISPLAY1 output_name completely or is it compatible with both device id and display id?

It will replace it completely, therefore the merging for this PR will only start after a new Sunshine release.

I also fetched it git fetch origin pull/2582/head:pr-2582 git checkout pr-2582 and compiled it. The compilation had some errors at the end but I could build the zip package.

This PR/build is no longer maintained and is left open only as a placeholder. If you want the latest, most-up-to-date build, check FrogTheFrog#2

Could you also develop a tool like dxgi-info.exe which will print out all display devices with their device id and display id?

No, it's already printed out in Sunshine logs.

@comsyspro
Copy link

Thank you for the explanation. So I should git clone this https://github.com/FrogTheFrog/Sunshine/tree/libdd-part-3 and checkout the branch libdd-part-3? Is this branch then also up to date with https://github.com/LizardByte/Sunshine or does it differ much?

@FrogTheFrog
Copy link
Collaborator Author

Thank you for the explanation. So I should git clone this https://github.com/FrogTheFrog/Sunshine/tree/libdd-part-3 and checkout the branch libdd-part-3? Is this branch then also up to date with https://github.com/LizardByte/Sunshine or does it differ much?

Yes, you can checkout that one and build, but you don't have to. You can also just download the binaries that are built by github.

I keep the branch up-to-date with Sunshine with my changes put on top of whatever new comes in. I usually rebase on Sunshine after some important stuff is added to Sunshine, like right now - they fixed the ffmpeg issues.

@comsyspro
Copy link

comsyspro commented Oct 12, 2024

Where can I find the build releases with your fork? On your page there are no releases published and on the sunshine page your branch isn't merged yet. Also, to understand it correctly, your method guarantees that the display device name is a fixed and unique value which is static as is and not like the previous display name which was dynamically generated by Windows right? Would ist be complicated to build a tool like the dxgi-info.exe for your device names because I want to create a initial setup script and without such a tool you have to start and stop the sunshine process to get these values. It is possible but it would be better to get these values without starting sunshine for this.

@FrogTheFrog
Copy link
Collaborator Author

Where can I find the build releases with your fork? On your page there are no releases published and on the sunshine page your branch isn't merged yet. Also, to understand it correctly, your method guarantees that the display device name is a fixed and unique value which is static as is and not like the previous display name which was dynamically generated by Windows right? Would ist be complicated to build a tool like the dxgi-info.exe for your device names because I want to create a initial setup script and without such a tool you have to start and stop the sunshine process to get these values. It is possible but it would be better to get these values without starting sunshine for this.

See #2582 (comment) on how to download binaries for forks.

You can build such tool yourself if you want. The functionality has been exported to a library which you could use. An here's even an example code: https://github.com/LizardByte/libdisplaydevice/blob/48ca85e8e7c3c01fef5db7f0befced7ea21d6238/tests/unit/windows/test_win_playground.cpp#L53

@ReenigneArcher
Copy link
Member

This PR/build is no longer maintained and is left open only as a placeholder.

Should I close this then?

@FrogTheFrog
Copy link
Collaborator Author

FrogTheFrog commented Oct 12, 2024

This PR/build is no longer maintained and is left open only as a placeholder.

Should I close this then?

Nay! I shall do it myself (once am back at the PC).

@FrogTheFrog
Copy link
Collaborator Author

Summary of the current state:

  1. This feature is still being worked on. The merging process will start once again after a new Sunshine version is released as the PR will bring in 1 breaking change.
  2. It will be a series of PRs, starting with this one feat(display)!: Add libdisplaydevice dependency and output name mapping #2894.
  3. The code in this PR/branch is severely outdated. To get the latest and the greatest version/build, go to this PR For CI build, part 2 FrogTheFrog/Sunshine#2, which is the (hopefully) final and full version that will be merged into Sunshine one day. It is being constantly rebased when some new features are merged to mainline Sunshine.

@LizardByte LizardByte locked as resolved and limited conversation to collaborators Oct 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants