Skip to content

Enable iterator-based Fabric props parsing by default - #60541

Open
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/push-props
Open

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/push-props

Conversation

@ide

@ide ide commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Enable enableCppPropsIteratorSetter by default. For components that support the iterator setter, Fabric copies the source props and calls setProp only for the supplied keys. Other components continue to use the classic constructor.

Make the two paths agree for the core components that support the iterator setter. The View setter reads the public shouldRasterizeIOS key instead of shouldRasterize, which JavaScript never sends. The TextInput setter reads minimumFontScale, lineBreak, wordBreak and experimental_textWidthMode, as the classic constructor does; AndroidTextInput sends minimumFontScale. When JavaScript removes width, height or the ScrollView horizontal prop, the classic constructor now restores the declared default that the setter restores: auto instead of an undefined length, and false instead of true.

Changelog:

[INTERNAL] [CHANGED] - Enable iterator-based props parsing for supported Fabric components.
[GENERAL] [FIXED] - Reset a removed ScrollView horizontal prop to false and a removed width or height to auto, as the iterator setter does.

Test Plan:

Parity tests build View, Paragraph, Text, Image, ScrollView and the cross-platform TextInput props from the same values with the classic constructor and with the setter. Each test gives a non-default value to every key that the type's own setter handles (for View, a selection across its categories), checks that each value takes effect, and checks that the two paths agree after setting the values and after removing them. The tests live with their components and share a helper in react/test_utils. Reverting any of the fixes above, or removing the setter case of a tested key, fails the matching check. The Android setters of View, ScrollView, Paragraph and AndroidTextInput do not build on this host; a comparison of the keys that their constructors and setters read finds no difference.

All ReactCommon C++ tests pass, built as the Fantom tester build does with this tree's generated code. A full yarn fantom run passes; two component-stack cases in LogBox-itest.js fail intermittently on this base with either flag value. The repository's C++ format check, yarn flow-check and yarn lint pass, and the C++ API snapshots validate.

An optimized C++ benchmark on Apple M6 clones ViewProps with six supplied props through ConcreteComponentDescriptor::cloneProps, running one binary with each flag value. Median retired instructions fall from 38,432 to 6,893 per clone.

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 4, 2026
ide added a commit to expo/react-native that referenced this pull request Dec 4, 2026
The classic Fabric props parser registers each name a component reads and keeps a view of its bytes for later lookups. A `const char*` name leaves that lifetime requirement unstated, and every lookup measures a length the compiler already knows.

This change adds `RawPropName` and uses it for the single-name `RawProps::at` and for `convertRawProp`. Its `consteval` constructor accepts string literals and static `constexpr` character arrays, so the compiler computes the length and the name has static storage. A name ends at its first NUL, or at the end of an array that has none. Generated code and calls that pass a literal keep their syntax.

Names built at run time go through the new `RawProps::atRuntime`. The parser copies such a name when it registers it, and later lookups compare against the argument without copying it. The three-argument prefix and suffix overload of `RawProps::at` uses `atRuntime`.

C++ code that passes a `const char*` or `std::string_view` name to `convertRawProp` or `RawProps::at` no longer compiles. A helper that forwards a declared name takes a `RawPropName` instead; code that builds a name at run time calls `atRuntime` and converts the returned `RawValue`.

react#60541 proposes making the iterator-based setter the default for components that support it. That path hashes each supplied name and calls `setProp` without the registered names, so this change does not affect it. Components that use the classic constructor keep the registered-name path.

`react_renderer_core_tests --gtest_filter='RawPropsTest.*:PropsConceptsTest.*:ComponentDescriptorTest.*'` passes in Debug. New tests look up a name without a terminating NUL and check that the parser copies composed names while it prepares. Compile-time checks accept string literals and reject `std::string`, `const char*` and `std::string_view` names.

The Debug View and TextInput prop tests pass. The generated Safe Area props compile, and the Android NDK compiles the TextInput and View prop sources. `FANTOM_FORCE_OSS_BUILD=1 yarn fantom --maxWorkers=4` passes, including the View tests with the iterator flag on and off. `python -m scripts.cxx-api.parser --validate` passes with Doxygen 1.16.1.

In an optimized build on an Apple M6, cloning `ViewProps` with six supplied props retires a median of 38,462 instructions on `075deb0d98` and 31,095 with this change on the classic path, 19.15% fewer. With the iterator flag on, the same clone retires 6,924 and 6,905.
@ide
ide force-pushed the @ide/push-props branch from f4d80a5 to 2601587 Compare December 4, 2026 11:33
ide added a commit to expo/react-native that referenced this pull request Dec 4, 2026
The classic Fabric props parser registers each name a component reads and keeps a view of its bytes for later lookups. A `const char*` name leaves that lifetime requirement unstated, and every lookup measures a length the compiler already knows.

This change adds `RawPropName` and uses it for the single-name `RawProps::at` and for `convertRawProp`. Its `consteval` constructor accepts string literals and static `constexpr` character arrays, so the compiler computes the length and the name has static storage. A name ends at its first NUL, or at the end of an array that has none. Generated code and calls that pass a literal keep their syntax.

Names built at run time go through the new `RawProps::atRuntime`. The parser copies such a name when it registers it, and later lookups compare against the argument without copying it. The three-argument prefix and suffix overload of `RawProps::at` uses `atRuntime`.

C++ code that passes a `const char*` or `std::string_view` name to `convertRawProp` or `RawProps::at` no longer compiles. A helper that forwards a declared name takes a `RawPropName` instead; code that builds a name at run time calls `atRuntime` and converts the returned `RawValue`.

react#60541 proposes making the iterator-based setter the default for components that support it. That path hashes each supplied name and calls `setProp` without the registered names, so this change does not affect it. Components that use the classic constructor keep the registered-name path.

`react_renderer_core_tests --gtest_filter='RawPropsTest.*:PropsConceptsTest.*:ComponentDescriptorTest.*'` passes in Debug. New tests look up a name without a terminating NUL and check that the parser copies composed names while it prepares. Compile-time checks accept string literals and reject `std::string`, `const char*` and `std::string_view` names.

The Debug View and TextInput prop tests pass. The generated Safe Area props compile, and the Android NDK compiles the TextInput and View prop sources. `FANTOM_FORCE_OSS_BUILD=1 yarn fantom --maxWorkers=4` passes, including the View tests with the iterator flag on and off. `python -m scripts.cxx-api.parser --validate` passes with Doxygen 1.16.1.

In an optimized build on an Apple M6, cloning `ViewProps` with six supplied props retires a median of 38,462 instructions on `075deb0d98` and 31,095 with this change on the classic path, 19.15% fewer. With the iterator flag on, the same clone retires 6,924 and 6,905.
ide added a commit to expo/react-native that referenced this pull request Dec 4, 2026
The classic Fabric props parser registers each name a component reads and keeps a view of its bytes for later lookups. A `const char*` name leaves that lifetime requirement unstated, and every lookup measures a length the compiler already knows.

This change adds `RawPropName` and uses it for the single-name `RawProps::at` and for `convertRawProp`. Its `consteval` constructor accepts string literals and static `constexpr` character arrays, so the compiler computes the length and the name has static storage. A name ends at its first NUL, or at the end of an array that has none. Generated code and calls that pass a literal keep their syntax.

Names built at run time go through the new `RawProps::atRuntime`. The parser copies such a name when it registers it, and later lookups compare against the argument without copying it. The three-argument prefix and suffix overload of `RawProps::at` uses `atRuntime`.

C++ code that passes a `const char*` or `std::string_view` name to `convertRawProp` or `RawProps::at` no longer compiles. A helper that forwards a declared name takes a `RawPropName` instead; code that builds a name at run time calls `atRuntime` and converts the returned `RawValue`.

react#60541 proposes making the iterator-based setter the default for components that support it. That path hashes each supplied name and calls `setProp` without the registered names, so this change does not affect it. Components that use the classic constructor keep the registered-name path.

`react_renderer_core_tests --gtest_filter='RawPropsTest.*:PropsConceptsTest.*:ComponentDescriptorTest.*'` passes in Debug. New tests look up a name without a terminating NUL and check that the parser copies composed names while it prepares. Compile-time checks accept string literals and reject `std::string`, `const char*` and `std::string_view` names.

The Debug View and TextInput prop tests pass. The generated Safe Area props compile, and the Android NDK compiles the TextInput and View prop sources. `FANTOM_FORCE_OSS_BUILD=1 yarn fantom --maxWorkers=4` passes, including the View tests with the iterator flag on and off. `python -m scripts.cxx-api.parser --validate` passes with Doxygen 1.16.1.

In an optimized build on an Apple M6, cloning `ViewProps` with six supplied props retires a median of 38,462 instructions on `075deb0d98` and 31,095 with this change on the classic path, 19.15% fewer. With the iterator flag on, the same clone retires 6,924 and 6,905.

Signed-off-by: James Ide <ide@expo.dev>
@ide
ide force-pushed the @ide/push-props branch from 2601587 to b5b18f2 Compare December 4, 2026 12:35
@ide
ide marked this pull request as ready for review December 4, 2026 14:37
@javache

javache commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

We need to restart the experimental rollout around this at Meta - this previously regressed things. I have since refactored the constructor approach, but haven't restarted any experiments.

@chrfalch chrfalch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shouldRasterizeIOS fix is correct. Before this change, the iterator setter listened for a "shouldRasterize" key that JavaScript never sends, so that prop was silently dropped when the flag was on. Turning the flag on by default moves every core Props type that declares its own setProp to the iterator path. That includes Image, ScrollView, Text and TextInput, not only View and Paragraph. A rough comparison of the keys read by each constructor and by each setProp found no other gaps, but the new parity tests cover only View and Paragraph. A parity test for each of the other types would guard against the next mismatch like shouldRasterizeIOS. The main code comment is about the hand-written case, which re-indents about 60 unrelated lines.

ide added a commit to expo/react-native that referenced this pull request Dec 5, 2026
The classic Fabric props parser registers each name a component reads and keeps a view of its bytes for later lookups. A `const char*` name leaves that lifetime requirement unstated, and every lookup measures a length the compiler already knows.

This change adds `RawPropName` and uses it for the single-name `RawProps::at` and for `convertRawProp`. Its `consteval` constructor accepts string literals and static `constexpr` character arrays, so the compiler computes the length and the name has static storage. A name ends at its first NUL, or at the end of an array that has none. Generated code and calls that pass a literal keep their syntax.

Names built at run time go through the new `RawProps::atRuntime`. The parser copies such a name when it registers it, and later lookups compare against the argument without copying it. The deprecated three-argument prefix and suffix overload of `RawProps::at` uses `atRuntime`, so the parser no longer keeps a view of the temporary string that overload composes.

A Props constructor that reads its props only under a condition that was false while the parser was prepared leaves the parser with no registered names. A lookup in such a parser now returns `nullptr` instead of reading the first element of an empty name list.

C++ code that passes a `const char*` or `std::string_view` name to `convertRawProp` or `RawProps::at` no longer compiles. A helper that forwards a declared name takes a `RawPropName` instead; code that builds a name at run time calls `RawProps::atRuntime` and converts the returned `RawValue`.

react#60541 proposes making the iterator-based setter the default for components that support it. That path hashes each supplied name and calls `setProp` without the registered names, so this change does not affect it. Components that use the classic constructor keep the registered-name path.

`react_renderer_core_tests --gtest_filter='RawPropsTest.*:PropsConceptsTest.*:ComponentDescriptorTest.*'` passes in Debug. New tests look up a name without a terminating NUL, check that the parser copies composed names while it prepares, and look up a name in a parser that registered none. Compile-time checks accept string literals and reject `std::string`, `const char*` and `std::string_view` names.

The Debug View and TextInput prop tests pass. The generated Safe Area props compile, and the Android NDK compiles the TextInput and View prop sources. `FANTOM_FORCE_OSS_BUILD=1 yarn fantom --maxWorkers=4` passes, including the View tests with the iterator flag on and off. `python -m scripts.cxx-api.parser --validate` passes with Doxygen 1.16.1.

In an optimized build on an Apple M6, cloning `ViewProps` with six supplied props retires a median of 38,462 instructions on `075deb0d98` and 31,095 with this change on the classic path, 19.15% fewer. With the iterator flag on, the same clone retires 6,924 and 6,905.

Signed-off-by: James Ide <ide@expo.dev>
Enable `enableCppPropsIteratorSetter` by default. For components that support the iterator setter, Fabric copies the source props and calls `setProp` only for the supplied keys. Other components continue to use the classic constructor.

Make the two paths agree for the core components that support the iterator setter. The View setter reads the public `shouldRasterizeIOS` key instead of `shouldRasterize`, which JavaScript never sends. The TextInput setter reads `minimumFontScale`, `lineBreak`, `wordBreak` and `experimental_textWidthMode`, as the classic constructor does; AndroidTextInput sends `minimumFontScale`. When JavaScript removes `width`, `height` or the ScrollView `horizontal` prop, the classic constructor now restores the declared default that the setter restores: `auto` instead of an undefined length, and `false` instead of `true`.

Parity tests build View, Paragraph, Text, Image, ScrollView and the cross-platform TextInput props from the same values with the classic constructor and with the setter. Each test gives a non-default value to every key that the type's own setter handles (for View, a selection across its categories), checks that each value takes effect, and checks that the two paths agree after setting the values and after removing them. The tests live with their components and share a helper in `react/test_utils`. Reverting any of the fixes above, or removing the setter case of a tested key, fails the matching check. The Android setters of View, ScrollView, Paragraph and AndroidTextInput do not build on this host; a comparison of the keys that their constructors and setters read finds no difference.

All ReactCommon C++ tests pass, built as the Fantom tester build does with this tree's generated code. A full `yarn fantom` run passes; two component-stack cases in `LogBox-itest.js` fail intermittently on this base with either flag value. The repository's C++ format check, `yarn flow-check` and `yarn lint` pass, and the C++ API snapshots validate.

An optimized C++ benchmark on Apple M6 clones `ViewProps` with six supplied props through `ConcreteComponentDescriptor::cloneProps`, running one binary with each flag value. Median retired instructions fall from 38,432 to 6,893 per clone.

Signed-off-by: James Ide <ide@expo.dev>
@ide
ide force-pushed the @ide/push-props branch from b5b18f2 to 5b900a5 Compare December 5, 2026 08:43
@ide

ide commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I added a parity test for each core Props type that supports the iterator setter: View, Paragraph, Text, Image, ScrollView and the cross-platform TextInput base. Each test gives a non-default value to every key that the type's own setter handles, checks that each value takes effect, and compares the two paths after setting the props and after removing them. The tests found three more mismatches, and this PR now fixes them. The TextInput setter ignored minimumFontScale, lineBreak, wordBreak and experimental_textWidthMode, which the classic constructor reads, and AndroidTextInput sends minimumFontScale. When width, height or the ScrollView horizontal prop is removed, the classic constructor fell back to an undefined length and to true, not to the declared defaults that the setter uses. This is the same kind of fix as #59125. The Android-only setters do not build in the Fantom tester, and a comparison of their keys found no difference. The commit is now rebased on main, because the regenerated feature flag files no longer applied.

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.

3 participants