Skip to content

Commit fc7dc74

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
Flip cxxNativeAnimatedEnabled featureflag default to true (#57204)
Summary: Pull Request resolved: #57204 ## Changelog: [General] [Changed] - Flip cxxNativeAnimatedEnabled featureflag default to true Reviewed By: javache Differential Revision: D108323433 fbshipit-source-id: 7f8157013bd7369ef520348db8b3f2eaf19a5e35
1 parent 723908a commit fc7dc74

5 files changed

Lines changed: 25 additions & 14 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

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<<98ed9f6f027f919cd31cd1e890750684>>
7+
* @generated SignedSource<<0dcc15b419f6805bdbeec4727ad94761>>
88
*/
99

1010
/**
@@ -27,7 +27,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
2727

2828
override fun cdpInteractionMetricsEnabled(): Boolean = false
2929

30-
override fun cxxNativeAnimatedEnabled(): Boolean = false
30+
override fun cxxNativeAnimatedEnabled(): Boolean = true
3131

3232
override fun defaultTextToOverflowHidden(): Boolean = true
3333

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h

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<<94d2315cb9bfc2684e18770eff3a1cf6>>
7+
* @generated SignedSource<<613be235a200f15ac2ec48d1f5d87053>>
88
*/
99

1010
/**
@@ -36,7 +36,7 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
3636
}
3737

3838
bool cxxNativeAnimatedEnabled() override {
39-
return false;
39+
return true;
4040
}
4141

4242
bool defaultTextToOverflowHidden() override {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const definitions: FeatureFlagDefinitions = {
7272
ossReleaseStage: 'none',
7373
},
7474
cxxNativeAnimatedEnabled: {
75-
defaultValue: false,
75+
defaultValue: true,
7676
metadata: {
7777
dateAdded: '2025-03-14',
7878
description:

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
7171
const shouldSignalBatch: boolean =
7272
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled();
7373

74+
// Schedules `API.flushQueue` after the current batch, replacing any pending
75+
// flush. On device `setImmediate` is a microtask; under jest's fake timers it's
76+
// a fake-timer entry that only `runAllTimers` drains — not `await` or
77+
// `advanceTimersByTime` — so the deferred flush wouldn't run before a test's
78+
// assertions. Flush synchronously in tests instead.
79+
function scheduleQueueFlush(): void {
80+
clearImmediate(flushQueueImmediate);
81+
if (process.env.NODE_ENV === 'test') {
82+
// TODO: T275950736 - remove this path
83+
API.flushQueue();
84+
} else {
85+
flushQueueImmediate = setImmediate(API.flushQueue);
86+
}
87+
}
88+
7489
function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
7590
const methodNames = [
7691
'createAnimatedNode', // 1
@@ -116,8 +131,7 @@ function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
116131
// details, see `NativeAnimatedModule.queueAndExecuteBatchedOperations`.
117132
singleOpQueue.push(operationID, ...args);
118133
if (shouldSignalBatch) {
119-
clearImmediate(flushQueueImmediate);
120-
flushQueueImmediate = setImmediate(API.flushQueue);
134+
scheduleQueueFlush();
121135
}
122136
};
123137
}
@@ -137,8 +151,7 @@ function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
137151
} else if (shouldSignalBatch) {
138152
// $FlowExpectedError[incompatible-call] - Dynamism.
139153
queue.push(() => method(...args));
140-
clearImmediate(flushQueueImmediate);
141-
flushQueueImmediate = setImmediate(API.flushQueue);
154+
scheduleQueueFlush();
142155
} else {
143156
// $FlowExpectedError[incompatible-call] - Dynamism.
144157
method(...args);
@@ -190,9 +203,7 @@ const API = {
190203
invariant(NativeAnimatedModule, 'Native animated module is not available');
191204

192205
if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) {
193-
const prevImmediate = flushQueueImmediate;
194-
clearImmediate(prevImmediate);
195-
flushQueueImmediate = setImmediate(API.flushQueue);
206+
scheduleQueueFlush();
196207
} else {
197208
API.flushQueue();
198209
}

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<<b3888619bcbd9d40b0e1740a864a07cf>>
7+
* @generated SignedSource<<1f64eab49a337feb5c9b1b41faf92730>>
88
* @flow strict
99
* @noformat
1010
*/
@@ -221,7 +221,7 @@ export const cdpInteractionMetricsEnabled: Getter<boolean> = createNativeFlagGet
221221
/**
222222
* Use a C++ implementation of Native Animated instead of the platform implementation.
223223
*/
224-
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', false);
224+
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', true);
225225
/**
226226
* When enabled, sets the default overflow style for Text components to hidden instead of visible.
227227
*/

0 commit comments

Comments
 (0)