Skip to content

Commit

Permalink
RN: Enable scheduleAnimatedEndCallbackInMicrotask
Browse files Browse the repository at this point in the history
Summary:
Enables the `scheduleAnimatedEndCallbackInMicrotask` feature flag that was introduced in #46714.

Changelog:
[General][Changed] - Callbacks passed to `animation.start(<callback>)` will be scheduled for execution in a microtask. Previously, there were certain scenarios in which the callback could be synchronously executed by `start`.

Differential Revision: D65645981
  • Loading branch information
yungsters authored and facebook-github-bot committed Nov 8, 2024
1 parent bc9d6a4 commit 560454e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ export default class Animation {
const callback = this.#onEnd;
if (callback != null) {
this.#onEnd = null;
if (ReactNativeFeatureFlags.scheduleAnimatedEndCallbackInMicrotask()) {
queueMicrotask(() => callback(result));
} else {
callback(result);
}
queueMicrotask(() => callback(result));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,6 @@ const definitions: FeatureFlagDefinitions = {
purpose: 'release',
},
},
scheduleAnimatedEndCallbackInMicrotask: {
defaultValue: false,
metadata: {
dateAdded: '2024-09-27',
description:
'Changes the completion callback supplied via `Animation#start` to be scheduled in a microtask instead of synchronously executed.',
purpose: 'experimentation',
},
},
shouldSkipStateUpdatesForLoopingAnimations: {
defaultValue: false,
metadata: {
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<<650ba11a0ac49b9779c6c98f57f7369f>>
* @generated SignedSource<<716c4507093099c254b57d744366bd05>>
* @flow strict
*/

Expand Down Expand Up @@ -37,7 +37,6 @@ export type ReactNativeFeatureFlagsJsOnly = {
enableAnimatedPropsMemo: Getter<boolean>,
enableOptimisedVirtualizedCells: Getter<boolean>,
isLayoutAnimationEnabled: Getter<boolean>,
scheduleAnimatedEndCallbackInMicrotask: Getter<boolean>,
shouldSkipStateUpdatesForLoopingAnimations: Getter<boolean>,
shouldUseAnimatedObjectForTransform: Getter<boolean>,
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter<boolean>,
Expand Down Expand Up @@ -154,11 +153,6 @@ export const enableOptimisedVirtualizedCells: Getter<boolean> = createJavaScript
*/
export const isLayoutAnimationEnabled: Getter<boolean> = createJavaScriptFlagGetter('isLayoutAnimationEnabled', true);

/**
* Changes the completion callback supplied via `Animation#start` to be scheduled in a microtask instead of synchronously executed.
*/
export const scheduleAnimatedEndCallbackInMicrotask: Getter<boolean> = createJavaScriptFlagGetter('scheduleAnimatedEndCallbackInMicrotask', false);

/**
* If the animation is within Animated.loop, we do not send state updates to React.
*/
Expand Down

0 comments on commit 560454e

Please sign in to comment.