@@ -1039,6 +1039,9 @@ AnimationMutations NativeAnimatedNodesManager::pullAnimationMutations(
10391039
10401040 isOnRenderThread_ = true ;
10411041
1042+ // Apply nodes created via the unbatched `createAnimatedNodeAsync` path.
1043+ flushAnimatedNodesCreatedAsync ();
1044+
10421045 // Run operations scheduled from AnimatedModule
10431046 std::vector<UiTask> operations;
10441047 {
@@ -1097,6 +1100,24 @@ AnimationMutations NativeAnimatedNodesManager::pullAnimationMutations(
10971100 return mutations;
10981101}
10991102
1103+ void NativeAnimatedNodesManager::flushAnimatedNodesCreatedAsync () noexcept {
1104+ // Flush async created animated nodes
1105+ std::unordered_map<Tag, std::unique_ptr<AnimatedNode>>
1106+ animatedNodesCreatedAsync;
1107+ {
1108+ std::lock_guard<std::mutex> lock (animatedNodesCreatedAsyncMutex_);
1109+ std::swap (animatedNodesCreatedAsync, animatedNodesCreatedAsync_);
1110+ }
1111+
1112+ if (!animatedNodesCreatedAsync.empty ()) {
1113+ std::lock_guard<std::mutex> lock (connectedAnimatedNodesMutex_);
1114+ for (auto & [tag, node] : animatedNodesCreatedAsync) {
1115+ animatedNodes_.insert ({tag, std::move (node)});
1116+ updatedNodeTags_.insert (tag);
1117+ }
1118+ }
1119+ }
1120+
11001121void NativeAnimatedNodesManager::onRender () {
11011122 if (ReactNativeFeatureFlags::useSharedAnimatedBackend ()) {
11021123 return ;
@@ -1112,23 +1133,7 @@ void NativeAnimatedNodesManager::onRender() {
11121133
11131134 isOnRenderThread_ = true ;
11141135
1115- {
1116- // Flush async created animated nodes
1117- std::unordered_map<Tag, std::unique_ptr<AnimatedNode>>
1118- animatedNodesCreatedAsync;
1119- {
1120- std::lock_guard<std::mutex> lock (animatedNodesCreatedAsyncMutex_);
1121- std::swap (animatedNodesCreatedAsync, animatedNodesCreatedAsync_);
1122- }
1123-
1124- if (!animatedNodesCreatedAsync.empty ()) {
1125- std::lock_guard<std::mutex> lock (connectedAnimatedNodesMutex_);
1126- for (auto & [tag, node] : animatedNodesCreatedAsync) {
1127- animatedNodes_.insert ({tag, std::move (node)});
1128- updatedNodeTags_.insert (tag);
1129- }
1130- }
1131- }
1136+ flushAnimatedNodesCreatedAsync ();
11321137
11331138 // Run operations scheduled from AnimatedModule
11341139 std::vector<UiTask> operations;
0 commit comments