Skip to content

Measure a node connected by enableMeasurement() again when its props or the font scale change - #60583

Open
YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/enable-measurement-without-measurable-trait
Open

YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/enable-measurement-without-measurable-trait

Conversation

@YevheniiKotyrlo

@YevheniiKotyrlo YevheniiKotyrlo commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

YogaLayoutableShadowNode::enableMeasurement() connects Yoga's measure function and sets no trait, while the two places that dirty a node for its measurement check the MeasurableYogaNode trait, not the measure function:

  • completeClone(), for a clone whose new revision invalidates its measurement;
  • configureYogaTree(), for a node whose fontSizeMultiplier changes.

A node measured through enableMeasurement() alone is therefore not dirtied when a new revision invalidates its measurement without changing its Yoga style, nor when the font scale changes, unless its component dirties it otherwise. Both conditions now read yogaNode_.hasMeasureFunc(), which holds for a node connected either way.

Related: #60571 adds enableBaseline() beside enableMeasurement(); #60572 adds getLayoutMargins(); #60578 corrects enableMeasurement()'s comment; #60581 passes the source revision to the shouldNewRevisionDirtyMeasurement() call in this condition of completeClone(). All four merge with this one without conflict. #59048 and #59139 add tests to ViewTest.cpp too; their changes to it merge with this one's without conflict.

Changelog:

[GENERAL] [FIXED] - Measure a node connected by enableMeasurement() again when its props or the font scale change

Test Plan:

FontScaleLayoutTest.enableMeasurementNodeIsMeasuredAgainOnPropsAndFontScaleChanges is new in ViewTest.cpp. In reactnativecommunity/react-native-android:latest with clang 18.1.8:

yarn install --non-interactive --frozen-lockfile
CC=clang-18 CXX=clang++-18 ./gradlew :private:react-native-fantom:configureFantomTester
/opt/android/cmake/3.30.5/bin/cmake --build private/react-native-fantom/build/tester --target react_renderer_components_view_tests -j24
/opt/android/cmake/3.30.5/bin/ctest --test-dir private/react-native-fantom/build/tester/react-common-tests -R <regex> --output-on-failure --output-junit /host/ctest.xml
  • this change, -R 'components/view/tests/': 100% tests passed, 0 tests failed out of 113
  • main with the new test alone, -R 'FontScaleLayoutTest\.enableMeasurementNode': fails; layoutIfNeeded() returns false after the props clone, and at font scale 1.5 the leaf keeps a fontSizeMultiplier of 1 and a height of 10
  • this change with completeClone() reading the trait again, same regex: fails at the props clone alone
  • this change with configureYogaTree() reading the trait again, same regex: fails at font scale 1.5 alone

node ./scripts/clang-format.js leaves the two changed files unchanged.

Not run here: the other CI jobs, among them testReactCommon's other suites, the Fantom tests, the Android and iOS builds, the C++ API snapshot validation and the format check.

…or the font scale change

completeClone() and configureYogaTree() read the MeasurableYogaNode trait to
decide whether a node is measured, and enableMeasurement() connects the
measure function without it. Both now read the Yoga node's measure function.
A case in ViewTest.cpp pins both paths.

Signed-off-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com>

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

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant