Instantiate Repeaters eagerly via an ensure_instantiated pass#11397
Open
Instantiate Repeaters eagerly via an ensure_instantiated pass#11397
Conversation
Member
Author
|
This will need more testing and figuring out if this has performance inmpact |
Add a new ItemTreeVTable method `ensure_instantiated` that walks the item tree and calls `ensure_updated` on every Repeater, Conditional and ComponentContainer. Generated code (Rust, C++, interpreter) implements it by recursing into children after materializing its own repeaters. Call this repeater instantiation pass from event-loop boundaries (process_mouse_input, process_key_input, draw_contents, show_popup) so init code that reads geometry runs outside any in-flight property evaluation. The testing backend tracks its TestingWindow instances and runs the instantiation pass on each of them in mock_elapsed_time, so internal tests that mutate a property and then read a layout value behave like a real event-loop tick without having to dispatch a full event. Adjust two existing tests whose assertions encoded the historical lazy init ordering (callbacks/init, models/if_dirty) and add regression tests for the linked issues. Fixes: #7402 Fixes: #9498 Fixes: #4522
814612f to
c93614e
Compare
tronical
approved these changes
Apr 16, 2026
| ) -> Option<T> { | ||
| // Must run before entering the redraw tracker scope so init code does | ||
| // not attach its geometry reads to it. | ||
| self.ensure_tree_instantiated(); |
Member
There was a problem hiding this comment.
I guess we'll end up sprinkling these over time - I can see that we might do this also in the access kit code :)
Member
Author
There was a problem hiding this comment.
thinking about it, we probably need to have a property scope, so we don't register any dependency
Actually remove the call from ensure_updated from the visiting code Make sure that the dependency are tracked. Add a test that property accessed in init do not trigger dedraw
tronical
approved these changes
Apr 17, 2026
| } | ||
|
|
||
| fn update_shadow_tree_recursive(&self, parent: &ItemRc) -> SharedVector<MenuEntry> { | ||
| vtable::VRc::borrow_pin(parent.item_tree()).as_ref().ensure_instantiated(); |
Member
There was a problem hiding this comment.
I've seen this twice at least. Perhaps worth a convenience functions on ItemRc? But feel free to ignore
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.
Add a new ItemTreeVTable method
ensure_instantiatedthat walks the item tree and callsensure_updatedon every Repeater, Conditional and ComponentContainer. Generated code (Rust, C++, interpreter) implements it by recursing into children after materializing its own repeaters.Call this repeater instantiation pass from event-loop boundaries (process_mouse_input, process_key_input, draw_contents, show_popup) so init code that reads geometry runs outside any in-flight property evaluation.
The testing backend tracks its TestingWindow instances and runs the instantiation pass on each of them in mock_elapsed_time, so internal tests that mutate a property and then read a layout value behave like a real event-loop tick without having to dispatch a full event.
Adjust two existing tests whose assertions encoded the historical lazy init ordering (callbacks/init, models/if_dirty) and add regression tests for the linked issues.
Fixes: #7402
Fixes: #9498
Fixes: #4522