Repository navigation
Only compute automatic minimum sizes for flex items that grow or shrink (#2073) - #2073
Merged
Merged
Conversation
adityasharat
force-pushed
the
export-D130643092
branch
from
November 10, 2026 09:38
33e6dfb to
c45fb03
Compare
adityasharat
added a commit
to adityasharat/yoga
that referenced
this pull request
Nov 10, 2026
…nk (react#2073) Summary: X-link: react/react-native#59906 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
adityasharat
force-pushed
the
export-D130643092
branch
from
November 10, 2026 09:45
c45fb03 to
10fbd11
Compare
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Nov 10, 2026
…nk (react#59906) Summary: X-link: react/yoga#2073 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
adityasharat
added a commit
to adityasharat/litho
that referenced
this pull request
Nov 10, 2026
…nk (meta#1095) Summary: X-link: react/yoga#2073 X-link: react/react-native#59906 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
adityasharat
added a commit
to adityasharat/yoga
that referenced
this pull request
Nov 11, 2026
…nk (react#2073) Summary: X-link: react/react-native#59906 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
adityasharat
force-pushed
the
export-D130643092
branch
from
November 11, 2026 09:22
10fbd11 to
cf7f21f
Compare
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Nov 11, 2026
…nk (react#59906) Summary: X-link: react/yoga#2073 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
adityasharat
added a commit
to adityasharat/litho
that referenced
this pull request
Nov 11, 2026
…nk (meta#1095) Summary: X-link: react/yoga#2073 X-link: react/react-native#59906 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Differential Revision: D130643092
…nk (react#2073) Summary: X-link: react/react-native#59906 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092
adityasharat
force-pushed
the
export-D130643092
branch
from
November 11, 2026 10:35
cf7f21f to
e8912ff
Compare
adityasharat
added a commit
to adityasharat/react-native
that referenced
this pull request
Nov 11, 2026
…nk (react#59906) Summary: X-link: react/yoga#2073 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092
adityasharat
added a commit
to adityasharat/litho
that referenced
this pull request
Nov 11, 2026
…nk (meta#1095) Summary: X-link: react/yoga#2073 X-link: react/react-native#59906 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092
meta-codesync Bot
pushed a commit
to meta/litho
that referenced
this pull request
Nov 11, 2026
…nk (#1095) Summary: X-link: react/yoga#2073 X-link: react/react-native#59906 Pull Request resolved: #1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092 fbshipit-source-id: 94a2a576f3fc41b80d687e8fda8fb09750b45bca
meta-codesync Bot
pushed a commit
to react/react-native
that referenced
this pull request
Nov 11, 2026
…nk (#59906) Summary: X-link: react/yoga#2073 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092 Pull Request resolved: #59906
This was referenced Nov 11, 2026
usama-liaqat
pushed a commit
to usama-liaqat/react-native
that referenced
this pull request
Nov 14, 2026
…nk (react#59906) Summary: X-link: react/yoga#2073 X-link: meta/litho#1095 With CSS Flexbox §4.5 automatic minimum sizing enabled, `resolveFlexibleLength` computed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (`boundAxisWithAutoMin`). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word. The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in `LayoutResults`'s existing bitfield, so node size does not grow. Changelog: [General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink Reviewed By: fbcbl Differential Revision: D130643092 Pull Request resolved: react#59906
meta-codesync Bot
pushed a commit
to meta/litho
that referenced
this pull request
Nov 20, 2026
Summary: Pull Request resolved: #1096 Fixes react/react-native#59678. With `enableFlexboxAutoMinSizeInStrictMode` on, a Text that holds a View under `<experimental_LayoutConformance mode="strict">` crashes on the JavaScript thread once a later commit lays its container out again while the Text stays as an earlier commit laid it out. `computeMinContentMainSize` walks the subtree of each flex item that grows or shrinks (since react/react-native#59906) through `getChild(i)` and measures the leaves it reaches, but unlike the rest of the algorithm it never calls `cloneChildrenIfNeeded()`. The pass runs before the item's own layout, which is what clones the item's children. When the item's flex basis comes from its style, or its measurement from its cache, nothing has cloned them yet, so the pass runs measure callbacks on, and writes its memoised results into, nodes the tree being laid out does not own. A committed `ParagraphShadowNode`'s cached content still points at the View its own `layout()` replaced with a laid-out clone, and React's reference to the View moved to that clone, so the View is already destroyed when the pass reads it. This clones a child before the pass measures or walks it, as `calculateLayoutImpl` clones before its writes and `layoutAbsoluteDescendants` does (react/yoga#1675), through `Node::cloneChildIfNeeded`, which this takes from react/yoga#2058. A child the pass skips, or whose min-content it only reads, stays shared, except below a `display: contents` node, which is cloned with its children. The pass can therefore leave a node's children part owned and part shared, a state `YGNodeInsertChild` into a clone already makes; `YGNodeRemoveAllChildren`, which React Native's renderer does not call, misreads it (react/yoga#2086). So that a relayout does not clone the subtree of every item that grows or shrinks, a memoised min-content now holds as long as the node's cached measurements do: the pass reuses it under the condition on which `calculateLayoutInternal` reuses them, which both now read from `isCacheStale`, and `calculateLayoutInternal` drops a memo from an earlier layout where it drops them. The 32-bit generation count now skips 0, which `LayoutResults` reserves for none, when it wraps: `main` takes 0 there for the current layout's generation, so a node the pass has not walked returns an undefined min-content. A container's memo is keyed on the owner's width only when its own percentage padding, or a percentage padding or margin below it, resolves against that width, as react/yoga#2042 keys a cached layout; its own percentage margin keys its parent's memo, since the parent's sum adds it. The pass resolves these percentages against the width as `main` does, where CSS resolves them against zero (react/yoga#2082). The two flags that record this take two bits of `LayoutResults`' existing bitfield, so a node stays the size it is on `main`. Because a memo now outlives its layout, `YGNodeSetMinContentWidth` and `YGNodeSetMinContentHeight` mark the node dirty when the value changes, as style setters do, and `YGMinContentMeasureFunc` says its results are kept, as a measure function's are, until the node is marked dirty. `yogaNodeMeasureCallbackConnector` now calls `ensureUnsealed()` on the node it measures, so a committed node reaching it asserts in debug builds where it happens rather than as a read of freed memory later. The Yoga cases are in `yoga/test/BaselineTest.cpp`, the file the internal target builds, and `test_react_common_cxx` now builds `yoga/test` as well as the `tests` directories. react/yoga#2077 exports an earlier head of this change to react/yoga. ## Changelog: [GENERAL] [FIXED] - Fix a crash measuring a Text that holds a View under strict layout conformance with automatic minimum sizes X-link: react/react-native#59688 Test Plan: - `yarn fantom Text-flexboxAutoMinSize-itest View-flexboxAutoMinSize-itest`: on `main` with only the two test files and the `ensureUnsealed()` assertion, the Text file aborts with `Attempt to mutate a sealed object.` and the two View cases pass; with this change both Text cases and both View cases pass, and so does `LayoutConformance-itest` with `enableFlexboxAutoMinSizeInStrictMode` on and off. - `MinContentTest` in `BaselineTest.cpp`: on `main` five of its eleven cases fail, `testWalkClonesChildrenOfAnotherTree`, `testUnchangedItemIsNotMeasuredAgain`, `testWalkClonesOnlyTheChildrenItWritesTo`, `testWalkMeasuresOnTheCloneOnlyTheAxisItCannotRead` and `testLayoutWhereGenerationWrapsMeasuresAsAnyOther`; with this change all eleven pass in `test_react_common_cxx`'s build, and in a build of Yoga alone with clang 18 on x86-64, with and without `-mfma`, and on aarch64. - react/yoga's tests at its head, react/yoga@cc937d5, which has react/react-native#59906 change as react/yoga#2073, pass with this change applied. - Cost, in callgrind's instructions per commit on a Release build, against `main` at 82dab20, for a commit that lays out again a column of 100 or 1,000 rows it leaves unchanged: where the rows grow, 8.6% fewer when a View below them changes and 20% fewer when the column's width changes; where they keep their size, for which `main` runs no pass since react/react-native#59906, the same as `main` within 0.01% ([counts](react/react-native#59688 (comment))). - CI: `validate_cxx_api_snapshots` passes in React Native's Android CI image, as do `yarn flow-check`, ESLint over the two tests and the formatters over the changed files, Yoga's with react/yoga's `.clang-format`. I could not run `test_ios_rntester`; Yoga's sources compile for the iOS simulator with `Yoga.podspec`'s flags. Reviewed By: javache Differential Revision: D130641328 Pulled By: adityasharat fbshipit-source-id: 6424d73a52fbfcb69c9fe979e2def7647671e2bc
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/react-native#59906
X-link: meta/litho#1095
With CSS Flexbox §4.5 automatic minimum sizing enabled,
resolveFlexibleLengthcomputed every in-flow item's automatic minimum main size up front, for every flex line on every layout pass. The value is only read when an item is bounded while growing or shrinking (boundAxisWithAutoMin). So a line with no free space to distribute, or an item that does not flex, paid for a min-content probe whose result was thrown away. For text, each probe scans and measures every word.The floor is now computed the first time an item is bounded on a line and cached on the item until the next line resets it. Layout results are unchanged; items that never grow or shrink no longer run the probe. The resolved flag lives in
LayoutResults's existing bitfield, so node size does not grow.Changelog:
[General][Changed] - Skip the automatic minimum size probe for flex items that neither grow nor shrink
Reviewed By: fbcbl
Differential Revision: D130643092