Skip to content

Walk only the requested axis for a container's min-content size (#2102) - #60481

Merged
javache merged 1 commit into
react:mainfrom
javache:export-D135328393
Dec 3, 2026
Merged

javache merged 1 commit into
react:mainfrom
javache:export-D135328393

Conversation

@javache

@javache javache commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • Walk only the requested axis for a container's min-content size

Why

The min-content walk behind automatic minimum sizes (css-flexbox-1 §4.5) is asked for a container's size on one axis. For every child it computed the size on both of the container's axes, summed one, took the largest of the other, and returned only the one it was asked for. The work on the other axis was wasted: a leaf was measured, and a container walked, on an axis no flex line needed.

How

The walk asks each child for the requested axis alone. It sums the children where that is the container's main axis and takes the largest where it is the cross axis. Layout results are unchanged. The memo already kept a leaf to one probe per axis per layout, so the saving is one measure call per leaf, and one walk per container, on the axis nobody asked for.

Test Plan

cmake --build tests/build && tests/build/yogatests passes. nested_leaf_probed_at_most_once_per_axis_per_layout, a measured leaf ten containers deep in a shrinking row, accepted up to two probes. It now expects one, and sees 2 without this change.

yarn gentest -h leaves the tree clean, and node ./scripts/clang-format.js --check passes.

Changelog:
[General][Changed] - Yoga calls a measure function for an automatic minimum size only on the axis it needs

  • Simplify alongMainAxis check and assert probed axis in test

Reviewed By: javache

Differential Revision: D135328393

@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 Dec 2, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Dec 2, 2026
@meta-codesync

meta-codesync Bot commented Dec 2, 2026

Copy link
Copy Markdown

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

meta-codesync Bot pushed a commit to meta/litho that referenced this pull request Dec 3, 2026
Summary:
X-link: react/react-native#60481

* Walk only the requested axis for a container's min-content size

Why
===
The min-content walk behind automatic minimum sizes (css-flexbox-1 §4.5) is asked for a container's size on one axis. For every child it computed the size on both of the container's axes, summed one, took the largest of the other, and returned only the one it was asked for. The work on the other axis was wasted: a leaf was measured, and a container walked, on an axis no flex line needed.

How
===
The walk asks each child for the requested axis alone. It sums the children where that is the container's main axis and takes the largest where it is the cross axis. Layout results are unchanged. The memo already kept a leaf to one probe per axis per layout, so the saving is one measure call per leaf, and one walk per container, on the axis nobody asked for.

Test Plan
=========
`cmake --build tests/build && tests/build/yogatests` passes. `nested_leaf_probed_at_most_once_per_axis_per_layout`, a measured leaf ten containers deep in a shrinking row, accepted up to two probes. It now expects one, and sees 2 without this change.

`yarn gentest -h` leaves the tree clean, and `node ./scripts/clang-format.js --check` passes.

Changelog:
[General][Changed] - Yoga calls a measure function for an automatic minimum size only on the axis it needs

* Simplify alongMainAxis check and assert probed axis in test

---------

Reviewed By: javache

Differential Revision: D135328393

fbshipit-source-id: c86df6ae6cd679bfb147ca8e148ea96b1d31b2f8

Co-authored-by: intergalacticspacehighway <nishanbende@gmail.com>
…t#2102)

Summary:
* Walk only the requested axis for a container's min-content size

Why
===
The min-content walk behind automatic minimum sizes (css-flexbox-1 §4.5) is asked for a container's size on one axis. For every child it computed the size on both of the container's axes, summed one, took the largest of the other, and returned only the one it was asked for. The work on the other axis was wasted: a leaf was measured, and a container walked, on an axis no flex line needed.

How
===
The walk asks each child for the requested axis alone. It sums the children where that is the container's main axis and takes the largest where it is the cross axis. Layout results are unchanged. The memo already kept a leaf to one probe per axis per layout, so the saving is one measure call per leaf, and one walk per container, on the axis nobody asked for.

Test Plan
=========
`cmake --build tests/build && tests/build/yogatests` passes. `nested_leaf_probed_at_most_once_per_axis_per_layout`, a measured leaf ten containers deep in a shrinking row, accepted up to two probes. It now expects one, and sees 2 without this change.

`yarn gentest -h` leaves the tree clean, and `node ./scripts/clang-format.js --check` passes.

Changelog:
[General][Changed] - Yoga calls a measure function for an automatic minimum size only on the axis it needs

* Simplify alongMainAxis check and assert probed axis in test

---------

Reviewed By: javache

Differential Revision: D135328393
@javache
javache merged commit 90724b8 into react:main Dec 3, 2026
73 of 75 checks passed
@javache
javache deleted the export-D135328393 branch December 3, 2026 14:59
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants