From 71caf2c55721ece18a36ea913b606aeb030f1fec Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 19 May 2025 13:49:27 -0700 Subject: [PATCH] Fix cross-over issue with animatedShouldUseSingleOp and animatedShouldSignalBatch (#51459) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51459 When using `animatedShouldSignalBatch` in combination with `animatedShouldUseSingleOp`, we were seeing an issue where the queue is not flushed deterministically. It would be flushed in an ad-hoc manner by `createAnimatedPropsHook.js`, but this was only if a mount happened to occur in the same frame. Adding a deterministic queue flush mechanism to the logic handling `animatedShouldUseSingleOp` appears to resolve the issue. ## Changelog [Internal] Reviewed By: javache Differential Revision: D75002657 fbshipit-source-id: 51f50af0f22becf152da15a720ba70dfc158cdbf --- .../react-native/src/private/animated/NativeAnimatedHelper.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/src/private/animated/NativeAnimatedHelper.js b/packages/react-native/src/private/animated/NativeAnimatedHelper.js index 24e4be916bc..3bede66b84e 100644 --- a/packages/react-native/src/private/animated/NativeAnimatedHelper.js +++ b/packages/react-native/src/private/animated/NativeAnimatedHelper.js @@ -97,6 +97,10 @@ function createNativeOperations(): $NonMaybeType { // is possible because # arguments is fixed for each operation. For more // details, see `NativeAnimatedModule.queueAndExecuteBatchedOperations`. singleOpQueue.push(operationID, ...args); + if (shouldSignalBatch) { + clearImmediate(flushQueueImmediate); + flushQueueImmediate = setImmediate(API.flushQueue); + } }; } } else {