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
In
LayoutStorage
we cache subelements, under the assumption that they will remain stable during a layout pass. This PR removes the caching, because it was a faulty assumption.Details
In
LayoutStorage
we currently assume the array ofLayoutSubelement
s for subelements will be stable during a layout pass, and cache it on theLayoutTreeNode
. This was assumed safe becauseLayoutStorage
-backed themselves elements cannot vary during a layout pass, andLazyStorage
, which can, does not cache its subelement at all.Turns out there is a case where this assumption is violated, if a
LazyStorage
produces a subtree that varies somewhere in a descendant node. For example, aGeometryReader
that contains a stack, and varies the number of children in the stack based on space available.Performance
This PR is broken into 2 commits:
LayoutMode
option. This option was used to performance test this change against the current behavior as a baseline.I was expecting to incur a hit from removing this caching but benchmarking showed it to be completely negligible, and attempts to more cleverly cache actually performed worse. I'll put up a Market PR that shows this benchmark and a regression test.
Testing
There's a new
GeometryReader
test to validate this case, and regression test will be on the Market side.See UI-4599.