Skip to content

fix(layout): preserve rounded root layouts on cache hits - #2074

Draft
hannojg wants to merge 1 commit into
react:mainfrom
hannojg:hannojg/fix-cached-layout-rounding
Draft

hannojg wants to merge 1 commit into
react:mainfrom
hannojg:hannojg/fix-cached-layout-rounding

Conversation

@hannojg

@hannojg hannojg commented Nov 10, 2026 •

Copy link
Copy Markdown

Calling YGNodeCalculateLayout twice with identical constraints can change an auto-height root from 58 to 57.666668, without measuring its content again. I reproduced #877 on both 9d159f2d and current main (41118bd3).

The layout cache stores unrounded measurements. A cache hit copies those values into the root's public layout dimensions, but the outer layout call skips pixel rounding because no layout was performed.

This preserves the root's rounded layout and hasNewLayout state when its full layout cache is reused. Cached descendants still restore their unrounded dimensions for the ancestor's rounding pass.

Added regression coverage for fractional widths and heights at different point scales, directly measured and content-sized roots, dirty measurements, and cached children whose parent moves. All 889 native tests pass in Debug and Release. The first two regressions fail with the original algorithm.

Changelog:
[General][Fixed] - Keep rounded Yoga root sizes stable when repeating a layout with unchanged constraints.

@meta-cla meta-cla Bot added the CLA Signed label Nov 10, 2026
@hannojg
hannojg force-pushed the hannojg/fix-cached-layout-rounding branch from 6b8ad0d to 0fd2a96 Compare November 10, 2026 13:56

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant