You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c9d9379
Browse filesBrowse the repository at this point in the historyBrowse files
Memoise §4.5 min-content per node and axis per layout (#58833)
Summary:
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
Differential Revision: D123012133
0 commit comments