Stop rebuilding the pie on every open and build it before the first frame - #73
Merged
Conversation
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.
Summary
Opening the menu tore down and rebuilt the entire visual tree every time, even when nothing had changed, and that rebuild was queued below render priority so it raced the fade-in. The result was inconsistent open latency: the pie could be on screen before the fade started, or pop in partway through it.
Two changes in
PieControl:OnIsVisibleChangedset_renderRefreshPending = trueunconditionally every time the menu was hidden, which forced a full rebuild on the next open. Hiding doesn't change anything. Real changes while hidden (theme, slices, size) already flag themselves throughRequestRenderRefresh, whose queued callback returns without clearing the flag while the control isn't visible, so they still rebuild on the next show.Renderinstead ofBackground. When a rebuild is genuinely needed, it now lands before the next frame is presented rather than whenever the dispatcher happens to drain.Measurements
Release build, 165 Hz display. "show->settled" is the time from making the control visible until no rebuild is outstanding and the tree is populated, sampled over 8 open/close cycles:
The rebuild itself was never expensive (2-6 ms median); the cost was doing it at all on every open, and doing it late. Worst case drops from 368 ms to 8 ms.
Verification
PieControlin a layered window matchingMainWindow's composition settings; visually identical to before.