Skip to content

Memoise §4.5 min-content per node and axis per layout (#58833) - #58833

Closed
adityasharat wants to merge 1 commit into
react:mainfrom
adityasharat:export-D123012133
Closed

adityasharat wants to merge 1 commit into
react:mainfrom
adityasharat:export-D123012133

Conversation

@adityasharat

@adityasharat adityasharat commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 4, 2026
@meta-codesync

meta-codesync Bot commented Oct 4, 2026

Copy link
Copy Markdown

@adityasharat has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123012133.

@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Oct 4, 2026
adityasharat added a commit to adityasharat/yoga that referenced this pull request Oct 8, 2026
Summary:

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

Differential Revision: D123012133
@meta-codesync meta-codesync Bot changed the title Memoise §4.5 min-content per node and axis per layout Memoise §4.5 min-content per node and axis per layout (#58833) Oct 8, 2026
adityasharat added a commit to adityasharat/react-native that referenced this pull request Oct 8, 2026
Summary:
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

Differential Revision: D123012133
adityasharat added a commit to adityasharat/yoga that referenced this pull request Oct 8, 2026
Summary:
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

Differential Revision: D123012133
adityasharat added a commit to adityasharat/react-native that referenced this pull request Oct 8, 2026
Summary:
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

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


`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 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/litho that referenced this pull request Oct 19, 2026
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
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
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
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
meta-codesync Bot pushed a commit to facebook/litho that referenced this pull request Oct 19, 2026
Summary:
Pull Request resolved: #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

fbshipit-source-id: 58eb649b260f5707cb36d4cd373e4f44788c16a2
@meta-codesync meta-codesync Bot closed this in 6e2edef Oct 19, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 19, 2026
@meta-codesync

meta-codesync Bot commented Oct 19, 2026

Copy link
Copy Markdown

This pull request has been merged in 6e2edef.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @adityasharat in 6e2edef

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants