Skip to content

Clear AnimatedPropsRegistry on surface stop (#56485)#56485

Open
zeyap wants to merge 1 commit intofacebook:mainfrom
zeyap:export-D101354994
Open

Clear AnimatedPropsRegistry on surface stop (#56485)#56485
zeyap wants to merge 1 commit intofacebook:mainfrom
zeyap:export-D101354994

Conversation

@zeyap
Copy link
Copy Markdown
Contributor

@zeyap zeyap commented Apr 17, 2026

Summary:

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 17, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 17, 2026

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101354994.

@zeyap zeyap force-pushed the export-D101354994 branch from a501e6f to ddbb31b Compare April 17, 2026 14:40
@meta-codesync meta-codesync bot changed the title Clear AnimatedPropsRegistry on surface stop Clear AnimatedPropsRegistry on surface stop (#56485) Apr 17, 2026
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 17, 2026
Summary:

## 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

Differential Revision: D101354994
@zeyap zeyap force-pushed the export-D101354994 branch from ddbb31b to 3045bc4 Compare April 17, 2026 14:59
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 17, 2026
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

Differential Revision: D101354994
@zeyap zeyap force-pushed the export-D101354994 branch 2 times, most recently from 9b9e54c to 49bdcf2 Compare April 17, 2026 20:24
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 17, 2026
Summary:

## 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
zeyap added a commit to zeyap/react-native that referenced this pull request Apr 17, 2026
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
@zeyap zeyap force-pushed the export-D101354994 branch from 49bdcf2 to f930d2e Compare April 17, 2026 20:28
Summary:

## 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
@zeyap zeyap force-pushed the export-D101354994 branch from f930d2e to 58f0814 Compare April 17, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant