Repository navigation
Memoise §4.5 min-content per node and axis per layout (#1089) - #1089
Closed
adityasharat wants to merge 1 commit into
Closed
adityasharat wants to merge 1 commit into
adityasharat wants to merge 1 commit into
Conversation
Contributor
|
@adityasharat has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123012133. |
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/yoga#2036 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
added a commit
to adityasharat/yoga
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
added a commit
to adityasharat/yoga
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
added a commit
to adityasharat/litho
that referenced
this pull request
Oct 19, 2026
Summary: X-link: react/yoga#2036 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
force-pushed
the
export-D123012133
branch
from
October 19, 2026 13:39
76e96e8 to
886d3b6
Compare
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/yoga#2036 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
Summary: Pull Request resolved: facebook#1089 X-link: react/yoga#2036 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
force-pushed
the
export-D123012133
branch
from
October 19, 2026 13:42
886d3b6 to
3421f42
Compare
adityasharat
added a commit
to adityasharat/yoga
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 Pull Request resolved: react#2036 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/yoga#2036 Pull Request resolved: react#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133
meta-codesync Bot
pushed a commit
to react/yoga
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/react-native#58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133 Pull Request resolved: #2036
Contributor
|
This pull request has been merged in f795c3e. |
meta-codesync Bot
pushed a commit
to react/react-native
that referenced
this pull request
Oct 19, 2026
Summary: X-link: facebook/litho#1089 X-link: react/yoga#2036 Pull Request resolved: #58833 `computeMinContentMainSize` asks every in-flow child of a container for its min-content along both axes, and every flex container's `resolveFlexibleLength` recomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout. This memoises min-content per node and axis for the current layout generation, following the existing `computedFlexBasisGeneration` pattern: - A leaf memoises its measured min-content, before its own padding and border. That value doesn't depend on the owner, so the measure callback runs at most once per axis per layout. - A container memoises its full min-content along with the `ownerWidth` it was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width. Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new `LayoutResults` fields. Changelog: [General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers Reviewed By: javache Differential Revision: D123012133 fbshipit-source-id: 58eb649b260f5707cb36d4cd373e4f44788c16a2
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:
X-link: react/yoga#2036
X-link: react/react-native#58833
computeMinContentMainSizeasks every in-flow child of a container for its min-content along both axes, and every flex container'sresolveFlexibleLengthrecomputes the automatic minimum size of each item. Nothing was cached, so a leaf with a measure function N containers below a flex item was probed O(2^N) times per call, then again for every ancestor and every layout pass. A text leaf ten containers deep was probed 7,161 times in a single layout.This memoises min-content per node and axis for the current layout generation, following the existing
computedFlexBasisGenerationpattern:ownerWidthit was computed against. Percentage padding and margins resolve against that width, and each ancestor probes with its own inner width, so a result is only reused for the same width.Layout results are unchanged; only the number of measure callbacks drops. The canonical Yoga copy and the React Native vendored copy are both updated, and the C++ API snapshots gain the three new
LayoutResultsfields.Changelog:
[General][Fixed] - Avoid exponential min-content measurement during automatic minimum sizing of nested flex containers
Reviewed By: javache
Differential Revision: D123012133