Stable UiStack - #25441
Merged
Merged
Conversation
…be_preserved_between_frames` inserts marker components to cause a table move, then checks that the order hasn't changed. `last_updated_root_should_be_on_top`: Spawns some root nodes with `GlobalZIndex(0)` and then reinserts `GlobalZIndex(0)` on the node at the bottom of the stack, and checks that it has moved to the top.
…vocabulary instead. The root of these stacks isn't necessarily a root node.
Added child stacks roots order test.
Zeophlite
reviewed
Aug 17, 2026
…at are equal must be new, and we only care about maintaining stability across frames).
…to stable-uistack
alice-i-cecile
approved these changes
Aug 20, 2026
|
|
||
| /// `GlobalZIndex` allows a [`Node`] entity anywhere in the UI hierarchy to escape the implicit draw ordering of the UI's layout tree and | ||
| /// be rendered above or below other UI nodes. | ||
| /// Root UI nodes without a `GlobalZIndex` component receive an implicit global z-index of `0`. |
Member
There was a problem hiding this comment.
This is a particularly useful subtle comment, thank you.
Zeophlite
approved these changes
Aug 20, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 20, 2026
cart
approved these changes
Aug 25, 2026
Member
|
The root sort is more expensive, but ideally we don't have toooooo many roots, so this seems fine to me. |
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.
Objective
The order of UI nodes with the same
GlobalZIndexinUiStackshould be stable across frames.Otherwise the order of UI nodes can change unpredictably after table moves. The associated issue has a simple example of this occuring.
Fixes #25410
Solution
If two Nodes have the same
GlobalZIndex, ties are now decided in order by::ZIndex.GlobalZIndexorZIndex.Otherwise the order is preserved from the previous frame. The previous ordering is stored in a local
EntityHashMap.Testing
Includes three new tests covering the new rules:
order_of_stack_roots_should_be_preserved_between_frameslast_updated_stack_root_should_be_on_toporder_of_parented_stack_roots_should_be_preserved_between_frames