Repository navigation
fix(windows): harden revert on inactive stream displays and preserve database-backed redock recovery - #334
Open
pperanich wants to merge 3 commits into
Conversation
…database-backed redock recovery Guard empty HDR and display mode queries during revert, prune stream-only devices that become inactive externally before or during revert, and preserve an already-restored initial topology in topology_prep_guard instead of force-enabling all displays into Extended mode. Also expose WinDisplayDeviceInterface::savesToDatabase() and persist optional pending topology and activated stream-only device metadata so database-backed CCD writes keep missing original displays pending until redock.
Author
|
|
|
10 of 18 tasks
Extract topology group filtering, pending-device collection, revert topology guard fallback, modified-topology switch recovery, and unified stream-only pruning/retry helpers in settings_manager_revert.cpp to reduce cognitive complexity and resolve SonarCloud findings, and share mock setup helpers in test_settings_manager_revert.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 hardens Windows
SettingsManagerrevert behavior when a stream-only (e.g., virtual) display is deactivated externally before or during revert, and adds database-backed pending topology recovery so callers can safely save Windows CCD changes to the display database without regressing laptop undock/redock recovery.Summary of Changes
revertModifiedHdrStates,revertModifiedDisplayModes):getCurrentHdrStates()/getCurrentDisplayModes()instead of proceeding intosetHdrStates()/setDisplayModes()or arming rollback guards against disappeared paths (which previously triggeredFailed to get all duplicated devices!followed byfailed to revert HDR states in hdrStateGuardFn!).m_initial.m_topology) drops out of active Windows paths before or during HDR/mode/primary revert, prune only the inactive stream-only device(s) and disarm stale rollback guards if all modified devices are gone (or continue reverting remaining active initial devices in mixed topologies).setTopology()during reactivation even while still enumerated, skip modified-settings cleanup for those stream-only devices so revert can proceed cleanly to the initial topology.topology_prep_guard:revertSettings()enters withcurrent_topologyalready equivalent tom_initial.m_topology, failure restorescurrent_topology(only if revert switched away) instead of callingcreateFullExtendedTopology()and force-enabling all available displays into Extended mode.savesToDatabase(),m_pending_topology_devices,m_activated_devices):WinDisplayDeviceInterface::savesToDatabase()(overridden inWinDisplayDeviceto returnm_save_to_database).pending_topology_devicesandactivated_devicesfields toSingleDisplayConfigState::Modified(omitted when empty during serialization; default empty when missing during deserialization).savesToDatabase()istrue,keepUnavailableSettings()keeps missing original displays pending until they return (without tracking temporary fallback panels across closed-lid cycles), andrecoverMissingTopology()keeps excluding stream-only devices from recovery topologies. This allows Sunshine to restoresave_to_database = true(fixing DisplayPort standby/wake/session-switch topology drops in Windows: display mode not kept and revert fails when displays are powered off (regression from #5625) SunshineStream/Sunshine#5942) without regressing closed-lid undock/redock recovery (fix(windows): preserve the saved display layout while streaming SunshineStream/Sunshine#5625).Screenshot
Issues Fixed or Closed
save_to_database = truewithout regressing fix(windows): preserve the saved display layout while streaming SunshineStream/Sunshine#5625, and fixes the disconnecthdrStateGuardFn/ Extended-mode fallback failure when a virtual display drops mid-stream).Roadmap Issues
Testing
Automated Unit Tests
Added regression tests covering every new code path:
tests/unit/windows/test_settings_manager_revert.cpp:RevertModifiedSettings_EmptyHdrQueryFailsWithoutCallingSetHdrStatesRevertModifiedSettings_EmptyModeQueryFailsWithoutCallingSetDisplayModesRevertModifiedSettings_StreamOnlyDeviceDropsBeforeHdrRevertSkipsModifiedCleanupRevertModifiedSettings_StreamOnlyDeviceDropsBeforeModeRevertRestoresInitialWithoutHdrGuardRevertModifiedSettings_StreamOnlyDeviceDropsBeforePrimaryRevertClearsPrimaryFieldsRevertModifiedSettings_StreamOnlyTopologyReactivationFailureSkipsModifiedCleanupRevertModifiedSettings_MixedTopologyPrunesInactiveStreamOnlyDeviceAndRevertsInitialDeviceTopologyGuard_PreservesInitialTopologyOnFailureInsteadOfEnablingAllDisplaysTopologyGuard_PreservesInitialTopologyLogsFailureWhenRestoreFailstests/unit/windows/test_settings_manager_undock.cpp:DatabaseBackedTopologyStaysPendingUntilClosedLidRedockDatabaseBackedPendingTopologySurvivesUndockedStreamAndClearsOnOpenLidRedockDatabaseBackedPartialRedockKeepsOnlyStillMissingDisplaysPendingtests/unit/windows/test_win_display_device_general.cpp:SavesToDatabase_ReflectsConstructorFlagtests/unit/windows/test_json_converter.cpp: round-trip serialization ofm_pending_topology_devicesandm_activated_devicesVerification runs:
test_libdisplaydevice.exe(MinGW GCC 16.2.0) and ran all non-hardware/mocked suites natively on Windows 11: 426/426 passed.gcovline coverage on modified files:json_serializer.cpp100%,types.h100%,settings_manager_apply.cpp100% of changed lines (98.27% overall),win_display_device_general.cpp100% of changed lines (98.36% overall),settings_manager_revert.cpp98.22% overall.WARN_AS_ERROR = YESvia Dockle config): 0 warnings.clang-format --style=file --dry-run --Werroron all modified files: 0 violations.Live Windows Hardware Validation
Linked into a local MSYS2 UCRT64 Sunshine build with
save_to_database = trueon Windows 11 Pro (RX 6800 + DisplayPort 4K@144Hz HDR monitor + virtual display):display_device.statewith zeroFailed to get all duplicated devices!,hdrStateGuardFn, orEnabling all of the available deviceserrors.Some modified devices are unavailable, reverting settings for the remaining topology:, kept the physical-only topology, and deleteddisplay_device.state.avail=0) during a 2+ minute stream,display_device.statepersisted across disconnect and a Sunshine service restart, then automatically reverted to physical-only and cleareddisplay_device.stateas soon as the monitor woke. (Note: reconnecting a new stream while all initial devices are asleep still hits the separatestripInitialState()path addressed by open PR fix(windows): apply settings while all initial devices are unavailable #330.)Live display-mutating unit tests (
WinDisplayDeviceTopology.*,WinDisplayDeviceModes.*,WinDisplayDevicePrimary.*,WinDisplayDeviceHdr.*) were not run locally to avoid mutating active host monitors and are left to CI.Type of Change
Checklist
AI Usage
See our AI usage policy.