Repository navigation
Conversation
added 3 commits
November 24, 2026 02:08
A text with no listener, props, tracked states or children no longer joins its parent's subviews: only its layer goes into the parent's container layer (#2066). AppKit's per-subview bookkeeping on insert is skipped, which took about 25-35% off Insert and about 15% off a batch's apply in the gallery's first screen. Leaves are only used under a plain view whose children are all leaves, so the layer order stays the child order. A leaf turns back into a view (with its siblings) once it gets a listener, props, tracked states or a child, or when a view child joins its parent. Picking, the accessibility children and names, selection, and the agent's bounds reach leaves through their parent. Agent: rust-maintainer
A leaf is in no view hierarchy, so `isDescendantOf:` and AppKit's window and backing-scale callbacks never reach it. Ask its parent in `root_containing`, the shader marks and the hover clean-up on removal, rescale leaves when their parent moves to a window or changes backing scale, and sharpen and tell `sight` on leaf insert and removal. Agent: rust-maintainer
AppKit takes a view's layer out of a view-backed layer whose view does not have it as a subview, so leaves put straight into their parent's layer disappeared after the next update. They now go into one plain layer per parent, which AppKit leaves alone, and that layer moves into the container when the parent gets one (it used to re-add the leaves' views as subviews there). Agent: rust-maintainer
This was referenced Nov 23, 2026
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.
Summary
Part of #2066. On macOS, a plain text node (no listener, no props, no tracked states, no children) no longer joins its parent's subviews: only its
CALayergoes into the parent's container layer. AppKit's per-subview bookkeeping on insert (geometry, display and accessibility tracking, layer-tree attach) is skipped for these nodes.Rules:
Viewwhose children are all leaves, so layer order is child order. Scroll views, stacks and views that host native AppKit views keep real subviews.Events), props (ViewProps), tracked states, or a child, or when a non-leaf child is inserted into its parent.input::pick_in/pick_children),child_views(selection walk, sticky cells, etc.),accessibilityChildren/accessibilityParent, a button's name gathered from its content,access::frame_of, and the agent'sbounds/text_boundsall reach leaves through their parent.CALayerper parent (inside its container layer). Put straight into a view-backed layer, AppKit removes a view's layer whose view is not a subview on the next update, and the texts vanished.isDescendantOf:checks that may see a leaf (window::root_containing, shader marks, hover clean-up on removal) ask the leaf's parent; leaves are rescaled when their parent moves window or backing scale, and sharpened on insert.The leaf still keeps its
ViewObj(its state lives in the NSView ivars). Not creating theViewObjat all would also take the Create cost down, but that means movingViewStateoff the NSView and is left for a follow-up.Performance
From an earlier measurement prototype (gallery, release build without LTO, 3 launches per group). The prototype put leaf layers straight into the parent's layer and had none of the fallbacks above, so this commit still needs its own A/B run:
These numbers are from the prototype, not re-measured on this commit; the extra host layer per parent and the fallbacks may take some of the gain back.
Tests
examples/gallery/tests/leaf-layers.test.tsx(macOS): a press on a leaf label reaches its button; the button's accessible name is read from the leaf; a leaf that gets a listener takes the press; leaf rows in a scroll view.copy-selection,accordion,button,data-table-interactionsrun on macOS against this branch.Results on a locked Mac mini (debug host): leaf-layers 4/4, accordion 4/4, button 7/7, data-table-interactions 20/22. The two data-table failures (the Tab stop test times out;
keyboard.downis unsupported) and all 7 copy-selection failures (no pressable view matches id:composer) fail the same way on main on that machine, so cross-text selection is not covered by this run.Screenshots (gallery, main vs this branch; only the live quote values differ):
Not verified
🤖 Noop (rust-maintainer) · AI agent acting for @huacnlee