Skip to content

Commit d201405

Browse files
zeyapfacebook-github-bot
authored andcommitted
clear up props registry in shared backend on js thread (facebook#56677)
Summary: ## Changelog: [Internal] [Fixed] - clear up props registry in shared backend on js thread stopSurface is usually called from main thread, but `animatedPropsRegistry_->getMap` in animationBackendCommitHook is called from js thread. Removing the surface props entry on ui thread can cause race condition (getMap() result on js thread becomes undefined) https://www.internalfb.com/code/fbsource/[26d70084020e]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/animationbackend/AnimationBackendCommitHook.cpp?lines=26-31 Reviewed By: christophpurrer Differential Revision: D103752709
1 parent 52ff392 commit d201405

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • packages/react-native/ReactCommon/react/renderer/uimanager

packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const {
275275
// Stop any ongoing layout animations.
276276
stopSurfaceForAnimationDelegate(surfaceId);
277277

278-
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
279-
animationBackend_->clearRegistryOnSurfaceStop(surfaceId);
280-
}
281-
282278
// Waiting for all concurrent commits to be finished and unregistering the
283279
// `ShadowTree`.
284280
auto shadowTree = getShadowTreeRegistry().remove(surfaceId);
@@ -295,6 +291,18 @@ ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const {
295291
leakChecker_->stopSurface(surfaceId);
296292
}
297293
}
294+
295+
runtimeExecutor_(
296+
[surfaceId,
297+
animationBackendWeak = std::weak_ptr<UIManagerAnimationBackend>(
298+
animationBackend_)](jsi::Runtime& runtime) {
299+
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
300+
if (auto animationBackend = animationBackendWeak.lock()) {
301+
animationBackend->clearRegistryOnSurfaceStop(surfaceId);
302+
}
303+
}
304+
});
305+
298306
return shadowTree;
299307
}
300308

0 commit comments

Comments
 (0)