From 7e646361ee50561ee8ddcc51f2577a3731eb2fe1 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 23 May 2022 07:57:42 -0700 Subject: [PATCH] Avoid start/finishOperationBatch when using singleOp Animated experiment Summary: Splitting these changes of from D36482630, which is a minor improvement to the singleOp experiment. Since we call start/finish already on the native side, we don't need to repeat it from JS. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D36541700 fbshipit-source-id: 7d61669710faca3153be557fb2d214011eda87c5 --- Libraries/Animated/NativeAnimatedHelper.js | 9 +++------ .../react/fabric/mounting/MountItemDispatcher.java | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 6e3ff5506c8..04e426e2e58 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -150,9 +150,6 @@ const API = { invariant(NativeAnimatedModule, 'Native animated module is not available'); flushQueueTimeout = null; - if (Platform.OS === 'android') { - NativeAnimatedModule.startOperationBatch?.(); - } if (useSingleOpBatching) { // Set up event listener for callbacks if it's not set up if ( @@ -168,13 +165,13 @@ const API = { NativeAnimatedModule.queueAndExecuteBatchedOperations?.(singleOpQueue); singleOpQueue.length = 0; } else { + Platform.OS === 'android' && NativeAnimatedModule.startOperationBatch?.(); for (let q = 0, l = queue.length; q < l; q++) { queue[q](); } queue.length = 0; - } - if (Platform.OS === 'android') { - NativeAnimatedModule.finishOperationBatch?.(); + Platform.OS === 'android' && + NativeAnimatedModule.finishOperationBatch?.(); } }, queueOperation: , Fn: (...Args) => void>( diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java index ca2e85ac26e..663634c2859 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java @@ -126,6 +126,8 @@ public class MountItemDispatcher { mInDispatch = false; } + // We call didDispatchMountItems regardless of whether we actually dispatched anything, since + // NativeAnimatedModule relies on this for executing any animations that may have been scheduled mItemDispatchListener.didDispatchMountItems(); // Decide if we want to try reentering