Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<061d668cf04041f4d3d2f48f11dc739f>>
* @generated SignedSource<<5f6861a5aa2d6024ad8d4c236652bf64>>
*/

/**
Expand All @@ -27,7 +27,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun cdpInteractionMetricsEnabled(): Boolean = false

override fun cxxNativeAnimatedEnabled(): Boolean = false
override fun cxxNativeAnimatedEnabled(): Boolean = true

override fun defaultTextToOverflowHidden(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8dfc52502bd539e5e43d547f895a6d33>>
* @generated SignedSource<<d0e19eae3c8e1f69383642a42172bb11>>
*/

/**
Expand Down Expand Up @@ -36,7 +36,7 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
}

bool cxxNativeAnimatedEnabled() override {
return false;
return true;
}

bool defaultTextToOverflowHidden() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
cxxNativeAnimatedEnabled: {
defaultValue: false,
defaultValue: true,
metadata: {
dateAdded: '2025-03-14',
description:
Expand Down
25 changes: 18 additions & 7 deletions packages/react-native/src/private/animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
const shouldSignalBatch: boolean =
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled();

// Schedules `API.flushQueue` after the current batch, replacing any pending
// flush. On device `setImmediate` is a microtask; under jest's fake timers it's
// a fake-timer entry that only `runAllTimers` drains — not `await` or
// `advanceTimersByTime` — so the deferred flush wouldn't run before a test's
// assertions. Flush synchronously in tests instead.
function scheduleQueueFlush(): void {
clearImmediate(flushQueueImmediate);
if (process.env.NODE_ENV === 'test') {
// TODO: T275950736 - remove this path
API.flushQueue();
} else {
flushQueueImmediate = setImmediate(API.flushQueue);
}
}

function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
const methodNames = [
'createAnimatedNode', // 1
Expand Down Expand Up @@ -116,8 +131,7 @@ function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
// details, see `NativeAnimatedModule.queueAndExecuteBatchedOperations`.
singleOpQueue.push(operationID, ...args);
if (shouldSignalBatch) {
clearImmediate(flushQueueImmediate);
flushQueueImmediate = setImmediate(API.flushQueue);
scheduleQueueFlush();
}
};
}
Expand All @@ -137,8 +151,7 @@ function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
} else if (shouldSignalBatch) {
// $FlowExpectedError[incompatible-call] - Dynamism.
queue.push(() => method(...args));
clearImmediate(flushQueueImmediate);
flushQueueImmediate = setImmediate(API.flushQueue);
scheduleQueueFlush();
} else {
// $FlowExpectedError[incompatible-call] - Dynamism.
method(...args);
Expand Down Expand Up @@ -190,9 +203,7 @@ const API = {
invariant(NativeAnimatedModule, 'Native animated module is not available');

if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) {
const prevImmediate = flushQueueImmediate;
clearImmediate(prevImmediate);
flushQueueImmediate = setImmediate(API.flushQueue);
scheduleQueueFlush();
} else {
API.flushQueue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<609451fd0a38e0f8eaf685e7cf534e27>>
* @generated SignedSource<<1de542d9c189f934f52fc258fd591b06>>
* @flow strict
* @noformat
*/
Expand Down Expand Up @@ -224,7 +224,7 @@ export const cdpInteractionMetricsEnabled: Getter<boolean> = createNativeFlagGet
/**
* Use a C++ implementation of Native Animated instead of the platform implementation.
*/
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', false);
export const cxxNativeAnimatedEnabled: Getter<boolean> = createNativeFlagGetter('cxxNativeAnimatedEnabled', true);
/**
* When enabled, sets the default overflow style for Text components to hidden instead of visible.
*/
Expand Down
Loading