Skip to content

Commit 590932f

Browse files
zeyapfacebook-github-bot
authored andcommitted
Disable single-op batching under C++ native animated, otherwise enable by default
Summary: Single-op batching (`queueAndExecuteBatchedOperations`) is incompatible with the C++ native animated backend. Move that guard out of per-product feature-flag overrides and into `NativeAnimatedHelper`: `isSingleOpBatching` is now gated on `Platform.OS === 'android'`, `queueAndExecuteBatchedOperations` being available, and `!cxxNativeAnimatedEnabled()`. With the invariant centralized, the redundant `animatedShouldUseSingleOp` overrides in the panel-app and igvr override files are removed (igvr keeps a passthrough override file wired into IGVRPrelude). **Single-op batching is most meaningful only on Android**: it collapses many per-operation JNI crossings into a single call, a significant win on the legacy bridge path. On other platforms (and on the C++/JSI path) the calls do not cross JNI, so batching would help performance only marginally while hurting debuggability — the ops are packed into an opaque serialized buffer and callbacks are rerouted through the device event emitter. That trade-off is why it stays Android-only and off under C++ native animated. Behavior note: with C++ native animated enabled (the default), this is a no-op — single-op was already forced off. Where C++ native animated is disabled on Android, single-op is now on by default (it was previously gated by the `animatedShouldUseSingleOp` flag, which defaulted to off). Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D109468772
1 parent b2602e9 commit 590932f

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ const definitions: FeatureFlagDefinitions = {
993993
ossReleaseStage: 'none',
994994
},
995995
animatedShouldUseSingleOp: {
996-
defaultValue: false,
996+
defaultValue: true,
997997
metadata: {
998998
dateAdded: '2024-02-05',
999999
description:

packages/react-native/src/private/animated/NativeAnimatedHelper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const singleOpQueue: Array<unknown> = [];
5656
const isSingleOpBatching =
5757
Platform.OS === 'android' &&
5858
NativeAnimatedModule?.queueAndExecuteBatchedOperations != null &&
59-
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
59+
ReactNativeFeatureFlags.animatedShouldUseSingleOp() &&
60+
!ReactNativeFeatureFlags.cxxNativeAnimatedEnabled();
6061
let flushQueueImmediate = null;
6162

6263
const eventListenerGetValueCallbacks: {

packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<c9804d0743d9a9d905193cb02816da46>>
7+
* @generated SignedSource<<f44477b5f5a4f7030798a61694d0332a>>
88
* @flow strict
99
* @noformat
1010
*/
@@ -164,7 +164,7 @@ export const animatedShouldSyncValueBeforeStartCallback: Getter<boolean> = creat
164164
/**
165165
* Enables an experimental mega-operation for Animated.js that replaces many calls to native with a single call into native, to reduce JSI/JNI traffic.
166166
*/
167-
export const animatedShouldUseSingleOp: Getter<boolean> = createJavaScriptFlagGetter('animatedShouldUseSingleOp', false);
167+
export const animatedShouldUseSingleOp: Getter<boolean> = createJavaScriptFlagGetter('animatedShouldUseSingleOp', true);
168168

169169
/**
170170
* Use the deferred cell render update mechanism for focus change in FlatList.

0 commit comments

Comments
 (0)