react-native-macos/Libraries/NativeAnimation
Samuel Susla c39a4c7f2e Flush operations queue when animation starts
Summary:
changelog: [internal]

If nodesManager has the information if animated node is managed by Fabric, we can't decide if the operation queue should be flushed before it is flushed. Therefore, keep the information about animated nodes inside a set instead of nodesManager.

For simplicity, I will refer to class `RCTNativeAnimatedTurboModule` as *NativeAnimated* and to `RCTNativeAnimatedNodesManager` as *NodesManager*

Notice that each call to *NativeAnimated* is queued up in `_operations` or `_preOperations`. When the queues are flushed, only then methods are called on `RCTNativeAnimatedNodesManager`.

There are two mechanisms that flush operations.
One is triggered by `RCTMountingManager` before mounting operations are applied and after they are applied. This works fine but is important to paint the picture.

The second mechanism is inside `[RCTNativeAnimatedTurboModule startAnimatingNode]`. It flushes the queues for Fabric nodes only (not sure why Fabric nodes only, I couldn't find any explanation in old diffs). It checks with *NativeAnimated* if a node is managed by Fabric. Keep in mind, *NodesManager* only knows about the nodes when the queues have been flushed.

Exampe:
JavaScript calls methods on *NativeAnimated*.
For example:
1. `createNode`
2. `connectAnimatedNodeToView`
3. `startAnimatingNode`. (here, the queues should be flushed, since we are in Fabric)

All of these operations are queued up and for as long as `RCTMountingManager` executes mounting, all proceeds as expected.
But if those operations happen after mounting phase, `startAnimatingNode` will not flush the operations queues, because it can't tell if nodeTag is managed by fabric or it isn't. This is because *NodesManager* hasn't been notified about any new nodes.

Reviewed By: JoshuaGross, p-sun

Differential Revision: D30053890

fbshipit-source-id: b7fe24861d5300f9cfefa813a53df8330fa56d86
2021-08-03 11:32:43 -07:00
..
Drivers Make RCTEventDispatcher TurboModule-compatible 2020-10-14 02:40:10 -07:00
Nodes Fix CircleCI breakage in RCTPropsAnimatedNode (#29800) 2020-08-31 11:39:54 -07:00
RCTAnimationPlugins.h Fork RCTAnimatedModule to unblock brideless mode 2020-07-27 15:09:33 -07:00
RCTAnimationPlugins.mm Fix crash in RCTCoreModulesClassProvider during quit 2021-04-28 13:29:06 -07:00
RCTAnimationUtils.h Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
RCTAnimationUtils.m Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
RCTNativeAnimatedModule.h Make RCTEventDispatcher TurboModule-compatible 2020-10-14 02:40:10 -07:00
RCTNativeAnimatedModule.mm Manual: Migrate from bridge.eventDispatcher to RCTModuleRegistry 2020-12-11 10:42:28 -08:00
RCTNativeAnimatedNodesManager.h Migrate RCTNativeAnimatedTurboModule to initialize 2021-05-21 14:49:51 -07:00
RCTNativeAnimatedNodesManager.m Migrate RCTNativeAnimatedTurboModule to initialize 2021-05-21 14:49:51 -07:00
RCTNativeAnimatedTurboModule.h Migrate RCTNativeAnimatedTurboModule to initialize 2021-05-21 14:49:51 -07:00
RCTNativeAnimatedTurboModule.mm Flush operations queue when animation starts 2021-08-03 11:32:43 -07:00
React-RCTAnimation.podspec Upgrade folly to 2021.06.28.00 and boost to 1.76.0 (#31840) 2021-07-16 15:13:12 -07:00