Skip to content

Commit 907b9d5

Browse files
zeyapfacebook-github-bot
authored andcommitted
Flip cxxNativeAnimatedEnabled featureflag default to true (#57204)
Summary: ## Changelog: [General] [Changed] - Flip cxxNativeAnimatedEnabled featureflag default to true Reviewed By: javache Differential Revision: D108323433
1 parent b99ddaf commit 907b9d5

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<<061d668cf04041f4d3d2f48f11dc739f>>
7+
* @generated SignedSource<<5f6861a5aa2d6024ad8d4c236652bf64>>
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<<8dfc52502bd539e5e43d547f895a6d33>>
7+
* @generated SignedSource<<d0e19eae3c8e1f69383642a42172bb11>>
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<<609451fd0a38e0f8eaf685e7cf534e27>>
7+
* @generated SignedSource<<1de542d9c189f934f52fc258fd591b06>>
88
* @flow strict
99
* @noformat
1010
*/
@@ -224,7 +224,7 @@ export const cdpInteractionMetricsEnabled: Getter<boolean> = createNativeFlagGet
224224
/**
225225
* Use a C++ implementation of Native Animated instead of the platform implementation.
226226
*/
227-
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', false);
227+
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', true);
228228
/**
229229
* When enabled, sets the default overflow style for Text components to hidden instead of visible.
230230
*/

0 commit comments

Comments
 (0)