Skip to content

Commit 86c833b

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 86c833b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

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

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,16 @@ 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-
}
278+
runtimeExecutor_(
279+
[surfaceId,
280+
animationBackendWeak = std::weak_ptr<UIManagerAnimationBackend>(
281+
animationBackend_)](jsi::Runtime& runtime) {
282+
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
283+
if (auto animationBackend = animationBackendWeak.lock()) {
284+
animationBackend->clearRegistryOnSurfaceStop(surfaceId);
285+
}
286+
}
287+
});
281288

282289
// Waiting for all concurrent commits to be finished and unregistering the
283290
// `ShadowTree`.

0 commit comments

Comments
 (0)