Stop the HDR toggle echoing a live change back as a request - #124
Merged
Conversation
HDRToggleView resyncs its switch from the live state on every screen-parameters notification, and every HDR flip fires one. The programmatic-change guard around that write does not hold, because SwiftUI runs onChange after the view update, by which time the flag is already reset, so each resync re-sent the value it had just read as a fresh setHDRPreference. Harmless while the toggle was the only writer, since the echo carries the same value, but each echo replaces the request token, and a request from anywhere else that is waiting out its settle at that moment is refused. Measured with crispctl's hdr set from #116: an off 0.3 s after an on was refused 4 times in 16, and 0 in 16 with this guard, which sends a request only when the switch differs from the live state.
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.
HDRToggleView resyncs its switch from the live state on every screen-parameters notification, and every HDR flip fires one. The programmatic-change guard around that write does not hold, because SwiftUI runs onChange after the view update, by which time the flag is already reset, so each resync re-sent the value it had just read as a fresh setHDRPreference. Harmless while the toggle was the only writer, but each echo replaces the request token, and a request from anywhere else waiting out its settle at that moment is refused. Measured with crispctl's hdr set from #116: an off 0.3 s after an on was refused 4 times in 16, and 0 in 16 with this guard, which sends a request only when the switch differs from the live state. The panel toggle itself was clicked on and off with the fix in and sent exactly one request each way.