Repository navigation
fix(display_device): restore Windows CCD database persistence and add opt-in display-loss reapply - #6189
Open
pperanich wants to merge 3 commits into
Conversation
… opt-in display-loss reapply Pass save_to_database = true to WinDisplayDevice on Windows so display wake, session switches, and DisplayPort standby/HPD resets do not revert the active stream topology (fixes SunshineStream#5942, paired with libdisplaydevice database-backed undock/redock recovery). Also add the opt-in dd_reapply_on_display_loss setting (disabled by default, Windows-only) to reapply the active display configuration with a cooldown if Windows externally drops the configured display mid-stream.
Author
|
…leanup Extract find_display_index, select_display_index, and try_reapply_displays in src/video.cpp to reduce cognitive complexity and nesting depth, use explicit std::optional::has_value() checks, consolidate active display-config resets into DD_DATA.clear_active_config(), and add fallback index coverage in tests/unit/test_video.cpp.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR restores Windows CCD display-database persistence (
save_to_database = true) forlibdisplaydeviceand adds an opt-in setting (dd_reapply_on_display_loss, disabled by default) to reapply the active stream's display configuration if Windows externally deactivates or drops the configured display mid-stream.Summary of Changes
save_to_database = trueon Windows (src/display_device.cpp):save_to_database = false(introduced in fix(windows): preserve the saved display layout while streaming #5625) makes Windows CCD changes session-only, causing DisplayPort monitor standby/HPD events (~16–22s afterensure_only_displaydisables a physical DisplayPort monitor), display wake, and session transitions to discard the active virtual-display topology and revert back to the physical monitor.save_to_database = truekeeps the active stream topology stable across DisplayPort standby HPD cycles.save_to_database = truedoes not regress fix(windows): preserve the saved display layout while streaming #5625) and hardens disconnect revert against externally deactivated stream-only displays. Note thatpackage-lock.cmakestill pins the currentlibdisplaydevicerelease tag until that PR merges and cuts a new tag.dd_reapply_on_display_loss):config::video_t::dd_t::reapply_on_display_loss(src/config.h,src/config.cpp, defaultfalse/disabled).SingleDisplayConfigurationinsrc/display_device.cpp(cleared on revert, reset, init, and deinit) and addeddisplay_device::reapply_configuration_on_display_loss()with a 2000 ms cooldown andVerifyOnlyguard.video::refresh_displays_with_callbacks()insrc/video.cppso that when the previously active display disappears mid-stream, Sunshine checks for a renumberedoutput_nameand—ifdd_reapply_on_display_lossis enabled—reapplies the active display configuration and re-enumerates before falling back to index0.DisplayDeviceOptions.vue, shown whendd_configuration_optionis notdisabledorverify_only), default entry inconfig_tabs.json, English localization inen.json, and documentation indocs/configuration.md.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
Automated Tests & Checks
tests/unit/test_config.cpp: default value andenabled/disabledparsing fordd_reapply_on_display_loss.tests/unit/test_display_device.cpp:DisplayDeviceReapplytests covering inactive/VerifyOnly/post-revert skips, active reapply, cooldown gating, and apply failure handling.tests/unit/test_video.cpp:VideoRefreshDisplaysTest(10 cases) covering display preservation, renumbered output recovery, fallback when disabled, reapply recovery on display loss and transient empty enumeration, reapply failure fallback, and initial selection.tests/web/Configuration.test.js: Vitest test verifyingdd_reapply_on_display_lossvisibility and toggle behavior acrossverify_onlyvs active preparation modes.-DBUILD_WERROR=ON):sunshine.exe, tools, Web UI,test_sunshine.exe) and passed the Windowslddlinkage check cleanly.test_sunshine.exe --gtest_filter="DisplayDevice*:VideoRefreshDisplaysTest.*:ConfigDefaultsTest.*:ConfigPersistenceTest.*:ConfigConsistencyTest.*:LocaleConsistencyTest.*": 199/199 passed.test_sunshine&gcovcoverage:display_device::reapply_configuration_on_display_loss()andvideo::refresh_displays_with_callbacks().npm test):tests/web/Configuration.test.jsand 23/23 intests/web/localization_files.test.jspassed (219/220 total; the 1 failure is an unrelated pre-existing Windows CRLF split intests/web/ExternalAudio.test.js:63).WARN_AS_ERROR = YES, full repo with_WIN32predefined): 0 warnings.uv run --locked lb-update-clang-format: PASS with zero unrelated diffs.Live Windows Hardware Validation
Tested on Windows 11 Pro (AMD Radeon RX 6800 + DisplayPort 4K@144Hz HDR physical monitor + persistent 3024×1890@120Hz HDR-capable virtual display) built with the companion
libdisplaydevicePR linked in:save_to_database = truewithdd_reapply_on_display_loss = disabled(default):dd_configuration_option = ensure_only_displaysurvived 5 DisplayPort standby HPD cycles each (between +21s and +59s) with zero drops off the virtual display.dd_reapply_on_display_loss = enabled:sunshine.conf). Simulating an externalSetDisplayConfigswitch back to the physical monitor mid-stream triggered automatic reapply and restored the virtual display (3024×1890 @ 120Hz HDR) in 455 ms, followed by clean revert to physical-only on disconnect.dd_reapply_on_display_loss = disabled):display_device.statewith zerohdrStateGuardFn/ Extended-mode fallback errors.Type of Change
Checklist
AI Usage
See our AI usage policy.