fix!: Wait for children added in onLoad before marking a component as loaded - #3999
Open
spydon wants to merge 1 commit into
Open
fix!: Wait for children added in onLoad before marking a component as loaded#3999spydon wants to merge 1 commit into
spydon wants to merge 1 commit into
Conversation
spydon
marked this pull request as ready for review
August 14, 2026 22:23
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.
Description
Stacked on #3998.
Previously, when a component was added to a running game and its
onLoadadded children of its own, the component was marked as loaded (and could mount) as soon as its ownonLoadfuture completed, while its children were still loading. The children then mounted one or more ticks later, so the component was visible and updating with an incomplete subtree.With this PR a component only counts as loaded once every child that was loading when its own
onLoadsettled has finished loading too, recursively (children gate the same way, so grandchildren added in a child'sonLoadare covered). Concretely:Component._finishLoadingnow waits, through the internalloadSettledfuture of each loading child, until no child is loading anymore, before completingloaded/isLoaded. Everything stays fully synchronous when there are no loading children.mountedfuture resolves, the subtree is mounted.Component.loaded/the currentZoneis unchanged.onLoad(for example children passed to the constructor of a detached component) keep the existing behavior of loading when the parent mounts.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Migration instructions
A component's
loadedfuture andisLoadedgetter now also wait for the children that were added during itsonLoad:onMount) instead of inonLoad.onLoadmust not await its parent'sloadedfuture, since the parent now waits for the child, that would deadlock.Related Issues
Related to #3997