Repository navigation
Compute the content bounds only of nodes whose children changed - #59999
Open
hryhoriiK97 wants to merge 1 commit into
Open
hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@javache when you have a moment, I'd like your opinion on the approach before going further. A node keeps its previous |
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:
After each layout,
YogaLayoutableShadowNode::layout()computesoverflowInsetfor every node with a new layout, by walking all its children ingetContentBounds(). Yoga also setshasNewLayouton nodes whose layout comes from its cache, without laying out their children again. So when one row changes in aScrollViewwith 500 rows, all rows are walked again: about 506getContentBounds()calls over 2,000 children per commit.Behind a new flag,
skipUnchangedOverflowInsetInLayout(off by default), a node keeps theoverflowInsetof its previous revision unless a child has a new layout or its props or children changed. A new member,overflowInsetNeedsUpdate_, tracks the second case. Clones inherit it likeyogaTreeHasBeenConfigured_, andappendChildandreplaceChildset it (except for Yoga's clone-on-write copies). The root of a layout always recomputes.ScrollViewShadowNodealso sets it when it moves right-to-left content after its own layout, so the member is protected and the C++ API snapshots have one new line.The result is the same as before: a size change makes Yoga lay out all children again, and any other change to a child gives it a new layout or a new props object or children list. When Yoga sets
hasNewLayoutdoesn't change, soonLayoutis unaffected.Changelog:
[INTERNAL] [ADDED] - Feature flag
skipUnchangedOverflowInsetInLayout, to skip computing the overflow insets of nodes whose children didn't changeTest Plan:
OverflowInsetTest, run with the flag off and on. It commits eight changes one after another and compares every node with a tree built from scratch, and it covers the right-to-leftScrollViewcase. All 107 tests incomponents/view/testspass. Without the new member, or without theScrollViewShadowNodeline, the tests fail with the flag on.overflowInsetboth ways found no difference in 13 scenario runs.ScrollView, one row changes every 250 msFlatListNot run:
yarn cxx-api-validate(no Doxygen here), so the snapshot line was added by hand.🤖 Generated with Claude Code