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 7c007b3
Browse filesBrowse the repository at this point in the historyBrowse files
Send only changed props on Insert of preallocated views with accumulated raw props (#58770)
Summary:
With `enableAccumulatedUpdatesInRawPropsAndroid`, `FabricMountingManager` handles every Insert by emitting `UpdateProps({}, new)`, which sends the view's full props again. The view already received those props at preallocation or from its Create item. So every inserted view's props are serialized and applied twice. The pull model (`enableMountingCoordinatorPullModelAndroid`) requires accumulated raw props and preallocates new views before the UI thread pulls the transaction, so under the pull model both happen on the UI thread.
For components with a Props 2.0 diff (`View`, with `enablePropsUpdateReconciliationAndroid`), this is also a correctness bug. The second payload is diffed against default props. If a prop goes back to its default between preallocation and mount, it is never sent, and the view keeps the preallocated value.
This PR adds `enablePreallocatedPropsDiffOnInsertAndroid`. It is off by default and only takes effect together with accumulated raw props.
- The allocated view registry also keeps the props each view was preallocated with, until the view's first Insert.
- That Insert sends only the difference between the preallocated and inserted props, or nothing when they are the same.
- A view created by a Create item already has its props, so its Insert sends nothing.
- A re-Insert of a mounted view (a move) also sends nothing. Its prop changes arrive through the Update mutation the differ emits with it.
- Held props are released on the first Insert, when an unmounted node is destroyed, or when the surface stops.
- With the flag off, the registry stores no props and the Insert path is unchanged.
In debug builds, Inserts of preallocated views now go through the Props 1.5 vs Props 2.0 validation in `getProps`. It can log props that Props 2.0 does not cover yet.
The flag keeps the change separately testable while `enableAccumulatedUpdatesInRawPropsAndroid` is being evaluated. The intent is to fold it into that flag once validated. I'm happy to make it unconditional now if that is preferred.
## Changelog:
[Internal] - Add `enablePreallocatedPropsDiffOnInsertAndroid`, which stops re-sending all props on Insert of preallocated views when `enableAccumulatedUpdatesInRawPropsAndroid` is on
Pull Request resolved: #58770
Test Plan:
- `yarn featureflags --verify-unchanged` and `yarn test packages/react-native/src/private/featureflags` pass. `yarn format-check-cpp` passes.
- `FabricMountingManager.cpp` compiles with the ReactAndroid arm64-v8a NDK flags. I did not run a full RNTester Android build of this exact revision.
- The runtime checks below used an earlier revision of this change with identical behaviour. The build also contained unrelated local fixes, present in both arms.
- Emulator, pull model and Props 2.0 flags on: a view whose `backgroundColor` and `opacity` are reset to their defaults between preallocation and mount keeps the old values with the flag off. With the flag on, it shows the defaults.
- OPPO A16 (low-end Android), release build, pull model and Props 2.0 flags on. The benchmark is a native screen that opens a React Native surface with placeholder cards, then a list of 24 cards. "First render" is the first React Native frame drawn. "Content drawn" is the first frame with the list. Flag on vs off in the same build:
| | flag off | flag on |
|---|---|---|
| Props updates on Insert, first render / content (Perfetto, 5 runs) | 90 / 100 | 2 / 0 |
| First render, median (35 runs per arm) | 384.8 ms | 364.2 ms |
| Content drawn, median (35 runs per arm) | 1209.6 ms | 1186.6 ms |
Paired within-round differences, 35 pairs: first render −20.6 ms [95% CI −26.8, −15.0], content drawn −22.0 ms [−43.4, −18.4]. Arms were interleaved.
Reviewed By: lenaic
Differential Revision: D122571252
Pulled By: bartlomiejbloniarz
fbshipit-source-id: 5922dd88f276ab41f0b57d851b89786fa4e3a6ec
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
* When enabled together with `enableAccumulatedUpdatesInRawPropsAndroid`, the Insert of a preallocated view only sends the difference between the props the view was preallocated with and the inserted props, instead of sending all props again on every Insert.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
0 commit comments