Skip to content

Commit f930d2e

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
Clear AnimatedPropsRegistry on surface stop (facebook#56485)
Summary: Pull Request resolved: facebook#56485 ## Changelog: [Internal] [Fixed] - Clear AnimatedPropsRegistry on surface stop When `useSharedAnimatedBackend` is enabled, the `AnimatedPropsRegistry` accumulates `SurfaceContext` entries (containing `shared_ptr<ShadowNodeFamily>` and `PropsSnapshot` data) for each surface that has animated views. These entries are never cleaned up when a surface is destroyed via `UIManager::stopSurface()`, because that method only calls the legacy `stopSurfaceForAnimationDelegate()` — the shared backend's registry is untouched. We also see increased `RetryableMountingLayerException` errors in production which stack trace shows there are mount items committing to surface that no longer exists. This change: 1. Adds `animationBackend_->clearRegistry(surfaceId)` to `UIManager::stopSurface()` 2. Changes `AnimatedPropsRegistry::clear()` to fully erase the `surfaceContexts_` map entry instead of just clearing its contents Reviewed By: christophpurrer Differential Revision: D101354994
1 parent 6530092 commit f930d2e

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimatedPropsRegistry.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ AnimatedPropsRegistry::getMap(SurfaceId surfaceId) {
9393

9494
void AnimatedPropsRegistry::clear(SurfaceId surfaceId) {
9595
auto lock = std::lock_guard(mutex_);
96-
97-
auto& surfaceContext = surfaceContexts_[surfaceId];
98-
surfaceContext.families.clear();
99-
surfaceContext.map.clear();
96+
surfaceContexts_.erase(surfaceId);
10097
}
10198

10299
} // namespace facebook::react

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,13 @@ void UIManager::setSurfaceProps(
272272
ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const {
273273
TraceSection s("UIManager::stopSurface");
274274

275-
// Stop any ongoing animations.
275+
// Stop any ongoing layout animations.
276276
stopSurfaceForAnimationDelegate(surfaceId);
277277

278+
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
279+
animationBackend_->clearRegistry(surfaceId);
280+
}
281+
278282
// Waiting for all concurrent commits to be finished and unregistering the
279283
// `ShadowTree`.
280284
auto shadowTree = getShadowTreeRegistry().remove(surfaceId);

0 commit comments

Comments
 (0)