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

HDR does not revert to On State upon disconnect #3580

Open
2 tasks done
lyndonguitar opened this issue Jan 22, 2025 · 15 comments
Open
2 tasks done

HDR does not revert to On State upon disconnect #3580

lyndonguitar opened this issue Jan 22, 2025 · 15 comments
Assignees

Comments

@lyndonguitar
Copy link

lyndonguitar commented Jan 22, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Is your issue present in the latest beta/pre-release?

None

Describe the Bug

Image

I am running into problems where a non-HDR client will turn off my HDR host as requested/expected, but upon full disconnect, it will not turn back on the HDR, but all other parameters (resolution+refresh rate) are reverted successfully.

Expected Behavior

Upon disconnect, HDR should be reverted to turned on state, if host has HDR on.

Additional Context

I reported it here before FrogTheFrog#2 (comment)
But I was not able to respond to @FrogTheFrog on time.

sunshine logs.txt

Host Operating System

Windows

Operating System Version

Win 11 24H2 Build 26100.2894

Architecture

amd64/x86_64

Sunshine commit or version

Sunshine v2025.118.151840

Package

Windows - installer (recommended)

GPU Type

AMD

GPU Model

RTX 3080

GPU Driver/Mesa Version

566.36

Capture Method

None

Config

upnp = enabled
display_mode_remapping = [{"type":"","received_resolution":"1680x1050","received_fps":"60","final_resolution":"2560x1600","final_refresh_rate":"60"},{"type":"","received_resolution":"1920x1080","received_fps":"60","final_resolution":"2560x1440","final_refresh_rate":"60"},{"type":"","received_resolution":"1920x1200","received_fps":"60","final_resolution":"2560x1600","final_refresh_rate":"60"},{"type":"","received_resolution":"1280x800","received_fps":"60","final_resolution":"2560x1600","final_refresh_rate":"60"},{"type":"","received_resolution":"","received_fps":"120","final_resolution":"2560x1440","final_refresh_rate":"120"},{"type":"","received_resolution":"3840x2160","received_fps":"60","final_resolution":"3840x2160","final_refresh_rate":"60"},{"type":"","received_resolution":"","received_fps":"","final_resolution":"","final_refresh_rate":""}]
fps = [10,30,60,90,120,144]
encoder = nvenc
dd_mode_remapping = {"mixed":[{"requested_fps":"","final_refresh_rate":"","requested_resolution":"1920x1080","final_resolution":"3840x2160"},{"requested_fps":"","final_refresh_rate":"","requested_resolution":"3840x2160","final_resolution":"3840x2160"},{"requested_fps":"","final_refresh_rate":"","requested_resolution":"2560x1440","final_resolution":"3840x2160"},{"requested_fps":"","final_refresh_rate":"","requested_resolution":"1280x800","final_resolution":"2560x1600"},{"requested_fps":"","final_refresh_rate":"","requested_resolution":"1920x1200","final_resolution":"2560x1600"},{"requested_fps":"","final_refresh_rate":"","requested_resolution":"1680x1050","final_resolution":"2560x1600"}],"resolution_only":[{"requested_resolution":"3840x2160","final_resolution":"3840x2160"},{"requested_resolution":"2560x1440","final_resolution":"3840x2160"},{"requested_resolution":"","final_resolution":""}],"refresh_rate_only":[]}
resolutions = [
    352x240,
    480x360,
    858x480,
    1280x720,
    1920x1080,
    2560x1080,
    3440x1440,
    1920x1200,
    3840x2160,
    3840x1600,
    2560x1440,
    1680x1050,
    2560x1600,
    1600x900
]
address_family = both
ping_timeout = 72000000
channels = 2
capture = ddx
display_device_prep = ensure_only_display
back_button_timeout = 2000

Apps

Relevant log output

[2025-01-23 00:37:34.428]: Info: Remapping requested display mode. Entry:
  - requested resolution: 1280x800
  - requested FPS: 
  - final resolution: 2560x1600
  - final refresh rate: 
[2025-01-23 00:37:34.456]: Info: Trying to apply display device settings. API is available: true
[2025-01-23 00:37:34.457]: Info: Using the following configuration:
{
  "device_id": "",
  "device_prep": "VerifyOnly",
  "hdr_state": "Disabled",
  "refresh_rate": {
    "type": "rational",
    "value": {
      "denominator": 1,
      "numerator": 60
    }
  },
  "resolution": {
    "height": 1600,
    "width": 2560
  }
}
[2025-01-23 00:37:34.457]: Info: Active topology before any changes:
[
  [
    "{64106ff7-725a-525c-a3b8-38ebaaab7a12}"
  ]
]
[2025-01-23 00:37:34.459]: Info: Currently available devices:
[
  {
    "device_id": "{64106ff7-725a-525c-a3b8-38ebaaab7a12}",
    "display_name": "\\\\.\\DISPLAY1",
    "friendly_name": "LG TV SSCR2",
    "info": {
      "hdr_state": "Enabled",
      "origin_point": {
        "x": 0,
        "y": 0
      },
      "primary": true,
      "refresh_rate": {
        "type": "rational",
        "value": {
          "denominator": 1000,
          "numerator": 143988
        }
      },
      "resolution": {
        "height": 2160,
        "width": 3840
      },
      "resolution_scale": {
        "type": "rational",
        "value": {
          "denominator": 100,
          "numerator": 125
        }
      }
    }
  }
]
[2025-01-23 00:37:34.459]: Info: Will compute new display device topology from the following input:
  - initial topology: [["{64106ff7-725a-525c-a3b8-38ebaaab7a12}"]]
  - initial primary devices: ["{64106ff7-725a-525c-a3b8-38ebaaab7a12}"]
  - configuring unspecified device: true
  - device to configure: "{64106ff7-725a-525c-a3b8-38ebaaab7a12}"
  - additional devices to configure: []
[2025-01-23 00:37:34.459]: Info: Newly computed display device topology data:
  - topology: [["{64106ff7-725a-525c-a3b8-38ebaaab7a12}"]]
  - change is needed: false
  - additional devices to configure: []
[2025-01-23 00:37:34.459]: Info: Changing display modes to:
{
  "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": {
    "refresh_rate": {
      "denominator": 1,
      "numerator": 60
    },
    "resolution": {
      "height": 1600,
      "width": 2560
    }
  }
}
[2025-01-23 00:37:35.182]: Info: Changing HDR states to:
{
  "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": "Disabled"
}
[2025-01-23 00:37:35.946]: Info: Encoder reenumeration is required
[2025-01-23 00:37:35.946]: Info: Trying encoder [nvenc]
[2025-01-23 00:37:36.415]: Info: 
Device Description : NVIDIA GeForce RTX 3080
Device Vendor ID   : 0x000010DE
Device Device ID   : 0x00002206
Device Video Mem   : 10053 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 16345 MiB
Feature Level      : 0x0000B100
Capture size       : 2560x1600
Offset             : 0x0
Virtual Desktop    : 2560x1600
[2025-01-23 00:37:36.415]: Info: Active GPU has HAGS enabled
[2025-01-23 00:37:36.415]: Info: Using realtime GPU priority
[2025-01-23 00:37:36.415]: Info: 
Colorspace         : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color     : 10
Red Primary        : [0.639646,0.330079]
Green Primary      : [0.299805,0.59961]
Blue Primary       : [0.150393,0.0595684]
White Point        : [0.3125,0.329098]
Min Luminance      : 0.0449 nits
Max Luminance      : 3600 nits
Max Full Luminance : 3600 nits
[2025-01-23 00:37:36.540]: Info: Desktop resolution [2560x1600]
[2025-01-23 00:37:36.540]: Info: Desktop format [DXGI_FORMAT_R16G16B16A16_FLOAT]
[2025-01-23 00:37:36.540]: Info: Display refresh rate [60Hz]
[2025-01-23 00:37:36.540]: Info: Requested frame rate [60fps]
[2025-01-23 00:37:36.540]: Info: Creating encoder [h264_nvenc]
[2025-01-23 00:37:36.540]: Info: Color coding: SDR (Rec. 601)
[2025-01-23 00:37:36.540]: Info: Color depth: 8-bit
[2025-01-23 00:37:36.540]: Info: Color range: JPEG
[2025-01-23 00:37:36.632]: Info: NvEnc: created encoder H.264 P1 two-pass rfi
[2025-01-23 00:37:36.684]: Info: Creating encoder [hevc_nvenc]
[2025-01-23 00:37:36.684]: Info: Color coding: SDR (Rec. 601)
[2025-01-23 00:37:36.684]: Info: Color depth: 8-bit
[2025-01-23 00:37:36.684]: Info: Color range: JPEG
[2025-01-23 00:37:36.790]: Info: NvEnc: created encoder HEVC P1 two-pass rfi
[2025-01-23 00:37:36.844]: Info: Creating encoder [av1_nvenc]
[2025-01-23 00:37:36.844]: Info: Color coding: SDR (Rec. 601)
[2025-01-23 00:37:36.844]: Info: Color depth: 8-bit
[2025-01-23 00:37:36.844]: Info: Color range: JPEG
[2025-01-23 00:37:36.894]: Error: NvEnc: encoding format is not supported by the gpu
[2025-01-23 00:37:36.917]: Info: Creating encoder [h264_nvenc]
[2025-01-23 00:37:36.917]: Info: Color coding: SDR (Rec. 601)
[2025-01-23 00:37:36.917]: Info: Color depth: 8-bit
[2025-01-23 00:37:36.917]: Info: Color range: JPEG
[2025-01-23 00:37:37.001]: Info: NvEnc: created encoder H.264 P1 yuv444 two-pass rfi
[2025-01-23 00:37:37.396]: Info: 
Device Description : NVIDIA GeForce RTX 3080
Device Vendor ID   : 0x000010DE
Device Device ID   : 0x00002206
Device Video Mem   : 10053 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 16345 MiB
Feature Level      : 0x0000B100
Capture size       : 2560x1600
Offset             : 0x0
Virtual Desktop    : 2560x1600
[2025-01-23 00:37:37.396]: Info: Active GPU has HAGS enabled
[2025-01-23 00:37:37.397]: Info: Using realtime GPU priority
[2025-01-23 00:37:37.397]: Info: 
Colorspace         : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color     : 10
Red Primary        : [0.639646,0.330079]
Green Primary      : [0.299805,0.59961]
Blue Primary       : [0.150393,0.0595684]
White Point        : [0.3125,0.329098]
Min Luminance      : 0.0449 nits
Max Luminance      : 3600 nits
Max Full Luminance : 3600 nits
[2025-01-23 00:37:37.412]: Info: Desktop resolution [2560x1600]
[2025-01-23 00:37:37.412]: Info: Desktop format [DXGI_FORMAT_R16G16B16A16_FLOAT]
[2025-01-23 00:37:37.412]: Info: Display refresh rate [60Hz]
[2025-01-23 00:37:37.412]: Info: Requested frame rate [60fps]
[2025-01-23 00:37:37.412]: Info: Creating encoder [hevc_nvenc]
[2025-01-23 00:37:37.412]: Info: Color coding: SDR (Rec. 709)
[2025-01-23 00:37:37.412]: Info: Color depth: 10-bit
[2025-01-23 00:37:37.412]: Info: Color range: JPEG
[2025-01-23 00:37:37.625]: Info: NvEnc: created encoder HEVC P1 yuv444 10-bit two-pass rfi
[2025-01-23 00:37:37.690]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2025-01-23 00:37:37.690]: Info: 
[2025-01-23 00:37:37.690]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2025-01-23 00:37:37.690]: Info: 
[2025-01-23 00:37:37.690]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2025-01-23 00:37:37.690]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
[2025-01-23 00:37:37.690]: Info: Executing [Desktop]
[2025-01-23 00:37:37.879]: Info: New streaming session started [active sessions: 1]
[2025-01-23 00:37:38.087]: Info: nvprefs: No need to modify application profile settings
[2025-01-23 00:37:38.087]: Info: nvprefs: No need to modify global profile settings
[2025-01-23 00:37:38.150]: Info: CLIENT CONNECTED
[2025-01-23 00:37:38.151]: Warning: QOSAddSocketToFlow() failed: 1168
[2025-01-23 00:37:38.333]: Info: Gamepad 0 will be Xbox 360 controller (default)
[2025-01-23 00:37:38.364]: Warning: QOSAddSocketToFlow() failed: 1168
[2025-01-23 00:37:38.409]: Info: Changed virtual audio sink format to [S24 48000 2.0]
[2025-01-23 00:37:38.545]: Info: Audio capture format is [F32 48000 2.0]
[2025-01-23 00:37:38.547]: Info: Opus initialized: 48 kHz, 2 channels, 512 kbps (total), LOWDELAY
[2025-01-23 00:37:38.565]: Info: 
Device Description : NVIDIA GeForce RTX 3080
Device Vendor ID   : 0x000010DE
Device Device ID   : 0x00002206
Device Video Mem   : 10053 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 16345 MiB
Feature Level      : 0x0000B100
Capture size       : 2560x1600
Offset             : 0x0
Virtual Desktop    : 2560x1600
[2025-01-23 00:37:38.565]: Info: Active GPU has HAGS enabled
[2025-01-23 00:37:38.565]: Info: Using realtime GPU priority
[2025-01-23 00:37:38.565]: Info: 
Colorspace         : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color     : 10
Red Primary        : [0.639646,0.330079]
Green Primary      : [0.299805,0.59961]
Blue Primary       : [0.150393,0.0595684]
White Point        : [0.3125,0.329098]
Min Luminance      : 0.0449 nits
Max Luminance      : 3600 nits
Max Full Luminance : 3600 nits
[2025-01-23 00:37:38.569]: Info: Desktop resolution [2560x1600]
[2025-01-23 00:37:38.569]: Info: Desktop format [DXGI_FORMAT_R16G16B16A16_FLOAT]
[2025-01-23 00:37:38.569]: Info: Display refresh rate [60Hz]
[2025-01-23 00:37:38.569]: Info: Requested frame rate [60fps]
[2025-01-23 00:37:38.570]: Info: Creating encoder [hevc_nvenc]
[2025-01-23 00:37:38.570]: Info: Color coding: SDR (Rec. 601)
[2025-01-23 00:37:38.570]: Info: Color depth: 8-bit
[2025-01-23 00:37:38.570]: Info: Color range: MPEG
[2025-01-23 00:37:38.588]: Info: Capture format [DXGI_FORMAT_R16G16B16A16_FLOAT]
[2025-01-23 00:37:38.666]: Info: NvEnc: created encoder HEVC P1 two-pass rfi
[2025-01-23 00:37:40.308]: Info: CLIENT DISCONNECTED
[2025-01-23 00:37:45.072]: Info: Trying to revert applied display device settings. API is available: true
[2025-01-23 00:37:45.074]: Info: Trying to change back the display modes to:
{
  "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": {
    "refresh_rate": {
      "denominator": 1000,
      "numerator": 143988
    },
    "resolution": {
      "height": 2160,
      "width": 3840
    }
  }
}
@FrogTheFrog
Copy link
Collaborator

@lyndonguitar Please try this build as it will have some additional logs for the relevant parts

@lyndonguitar
Copy link
Author

@lyndonguitar Please try this build as it will have some additional logs for the relevant parts

thank you, what build should I try?

@FrogTheFrog
Copy link
Collaborator

Welp, brainfart on my end :D

This FrogTheFrog#5

@lyndonguitar
Copy link
Author

Welp, brainfart on my end :D

This FrogTheFrog#5

thanks, this is the full log.

sunshine logs.txt

There seems to be an error involving the HDR state?

[2025-01-23 18:07:00.968]: Info: Trying to revert applied display device settings. API is available: true [2025-01-23 18:07:00.968]: Error: LOL cached_state->m_modified.m_original_hdr_states: { "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": "Enabled" } [2025-01-23 18:07:00.969]: Error: LOL current_states: { "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": "Enabled" } [2025-01-23 18:07:00.969]: Error: LOL NE: false [2025-01-23 18:07:00.969]: Info: Trying to change back the display modes to: { "{64106ff7-725a-525c-a3b8-38ebaaab7a12}": { "refresh_rate": { "denominator": 1000, "numerator": 143988 }, "resolution": { "height": 2160, "width": 3840 } } }

@FrogTheFrog
Copy link
Collaborator

It's most likely a bug on Windows side as we are asking it directly... Could you also please enable verbose logging and give me the logs again.

@lyndonguitar
Copy link
Author

It's most likely a bug on Windows side as we are asking it directly... Could you also please enable verbose logging and give me the logs again.

sunshine logs.txt

Try this log with verbose on. I did a quick HDR on - > connect -> HDR off -> disconnect -> HDR still off

@FrogTheFrog
Copy link
Collaborator

Yeah, it some sort of Windows or driver bug, OR new windows API needs to be used. I will try to integrate the new API just for you and we can check if that helps.

Will have a new build for you tomorrow probably.

@lyndonguitar
Copy link
Author

Yeah, it some sort of Windows or driver bug, OR new windows API needs to be used. I will try to integrate the new API just for you and we can check if that helps.

Will have a new build for you tomorrow probably.

big thank you for the help! I'll try it asap once available.

@FrogTheFrog
Copy link
Collaborator

One question, you did not complain about this for some time (before you first noticed the bug). Was it working correctly or did you not use this feature?

@lyndonguitar
Copy link
Author

One question, you did not complain about this for some time (before you first noticed the bug). Was it working correctly or did you not use this feature?

I did not use the feature before, only the resolution change. But eventually I tried HDR auto-change, i didnt immediately notice that there was an issue, just continued using it.

Eventually I started to notice that my HDR was getting turned off seemingly randomly (I would use the host monitor for days with HDR turned off because of this). I would turn it on, be fine, and then I would stumble upon it turned off again in which i didnt know why. Then when I checked deeper I found out that it was Sunshine that was turned it it off but not turning it back on.

@FrogTheFrog
Copy link
Collaborator

@lyndonguitar I've pushed the update so can grab the new build whenever you fancy it.

@lyndonguitar
Copy link
Author

@lyndonguitar I've pushed the update so can grab the new build whenever you fancy it.

Can verify with quick connect disconnect testing that it does properly turn off and on the HDR now. Uploading the Verbose logs that covers the event.

sunshine logs.txt

Thank you so much for this

I'm curious as to what changed? Was this a wide-spread issue? are you also experiencing this? or is it specific to certain configurations/setups?

@FrogTheFrog
Copy link
Collaborator

Around 7 months ago Windows introduced a new API that allows to query and change "advanced_color_info_2":

  typedef struct _DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO_2 {
    DISPLAYCONFIG_DEVICE_INFO_HEADER header;
    __C89_NAMELESS union {
      __C89_NAMELESS struct {
        UINT32 advancedColorSupported : 1;
        UINT32 advancedColorActive : 1;
        UINT32 reserved1 : 1;
        UINT32 advancedColorLimitedByPolicy : 1;
        UINT32 highDynamicRangeSupported : 1;
        UINT32 highDynamicRangeUserEnabled : 1;
        UINT32 wideColorSupported : 1;
        UINT32 wideColorUserEnabled : 1;
        UINT32 reserved : 24;
      };
      UINT32 value;
    };
    DISPLAYCONFIG_COLOR_ENCODING colorEncoding;
    UINT32 bitsPerColorChannel;
    DISPLAYCONFIG_ADVANCED_COLOR_MODE activeColorMode;
  } DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO_2;

  typedef struct _DISPLAYCONFIG_SET_HDR_STATE {
    DISPLAYCONFIG_DEVICE_INFO_HEADER header;
    __C89_NAMELESS union {
      __C89_NAMELESS struct {
        UINT32 enableHdr : 1;
        UINT32 reserved : 31;
      };
      UINT32 value;
    };
  } DISPLAYCONFIG_SET_HDR_STATE;

Before you could only ask for this info in "advanced_color_info" (v1):

        UINT32 advancedColorSupported : 1;
        UINT32 advancedColorEnabled : 1;

What advancedColor is, is up to interpretation really, but in most cases it was HDR and you could turn this advancedColor on/off. However, as you can see we now have highDynamicRange and wideColor, and advancedColor. So, what really is advancedColor then?

Anyways, what's changed now is that I use highDynamicRangeSupported and highDynamicRangeUserEnabled to query for HDR info and enableHdr to turn it on/off.

@FrogTheFrog
Copy link
Collaborator

I'll need to cleanup/finalize everything and once it's done, I'll ask you to test it again plz.

@FrogTheFrog
Copy link
Collaborator

@lyndonguitar please test the latest build when you can to make sure it still works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants