Skip to content

Fix RetryableMountingLayerException crash in updateOverflowInset - #56762

Closed
javache wants to merge 1 commit into
react:mainfrom
javache:export-D104400233
Closed

javache wants to merge 1 commit into
react:mainfrom
javache:export-D104400233

Conversation

@javache

@javache javache commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary:
Fix a crash in SurfaceMountingManager.updateOverflowInset() where getViewState() throws RetryableMountingLayerException when the view state for a tag is not found in the registry.

The crash occurs during batch mount item execution when an updateOverflowInset operation references a view tag that has been removed from the registry due to normal lifecycle race conditions. The surface is still active (not stopped), but the view has already been deleted.

The fix replaces getViewState(reactTag) (which throws) with getNullableViewState(reactTag) + null check + soft exception logging + early return. This matches the defensive pattern already used by peer methods in the same class: updateLayout, addViewAt, and removeViewAt.

Logview link: 252c85116a7ab5c4ec93ef3c3373cf9d

Differential Revision: D104400233

Summary:
Fix a crash in `SurfaceMountingManager.updateOverflowInset()` where `getViewState()` throws `RetryableMountingLayerException` when the view state for a tag is not found in the registry.

The crash occurs during batch mount item execution when an `updateOverflowInset` operation references a view tag that has been removed from the registry due to normal lifecycle race conditions. The surface is still active (not stopped), but the view has already been deleted.

The fix replaces `getViewState(reactTag)` (which throws) with `getNullableViewState(reactTag)` + null check + soft exception logging + early return. This matches the defensive pattern already used by peer methods in the same class: `updateLayout`, `addViewAt`, and `removeViewAt`.

Logview link: [252c85116a7ab5c4ec93ef3c3373cf9d](https://www.internalfb.com/logview/system_vros_crashes/252c85116a7ab5c4ec93ef3c3373cf9d)

Differential Revision: D104400233
@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 May 11, 2026
@meta-codesync

meta-codesync Bot commented May 11, 2026

Copy link
Copy Markdown

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

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in dabb434 May 11, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @javache in dabb434

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label May 11, 2026
@javache
javache deleted the export-D104400233 branch May 12, 2026 10:32
cipolleschi pushed a commit that referenced this pull request Aug 24, 2026
)

Summary:
Pull Request resolved: #56762

Fix a crash in `SurfaceMountingManager.updateOverflowInset()` where `getViewState()` throws `RetryableMountingLayerException` when the view state for a tag is not found in the registry.

The crash occurs during batch mount item execution when an `updateOverflowInset` operation references a view tag that has been removed from the registry due to normal lifecycle race conditions. The surface is still active (not stopped), but the view has already been deleted.

The fix replaces `getViewState(reactTag)` (which throws) with `getNullableViewState(reactTag)` + null check + soft exception logging + early return. This matches the defensive pattern already used by peer methods in the same class: `updateLayout`, `addViewAt`, and `removeViewAt`.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D104400233

fbshipit-source-id: 678df406079da98c0c2180766c936b5f2bb9fcf7
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @javache in 09dcc63

When will my fix make it into a release? | How to file a pick request?

delekta added a commit to discord/react-native that referenced this pull request Nov 23, 2026
…updateState and updateOverflowInset (#66)

* Handle missing viewState gracefully in SurfaceMountingManager.updateState and updatePadding (react#57181)

Summary:
Pull Request resolved: react#57181

## Summary

Fixes `RetryableMountingLayerException: Unable to find viewState for tag N. Surface stopped: false` crashing `com.oculus.firsttimenux` from the Fabric batch-mount path.

Logview link: [252c85116a7ab5c4ec93ef3c3373cf9d](https://www.internalfb.com/logview/system_vros_crashes/252c85116a7ab5c4ec93ef3c3373cf9d)

## Root cause

`IntBufferBatchMountItem.execute` dispatches batched mount instructions. When a view tag is transiently missing from the registry (async race between the JS commit and native mount — surface teardown / out-of-order delivery), mount methods that call the throwing `getViewState` raise `RetryableMountingLayerException`. `MountItemDispatcher.dispatchMountItems` only retries this exception `if (item is DispatchCommandMountItem)` (comment: *"Only DispatchCommandMountItem supports retries"*) — `IntBufferBatchMountItem` is not one, so the "retryable" exception propagates uncaught and crashes the app.

The RN team has been hardening each batch mount method to handle missing viewState gracefully (soft-log + early return): `addViewAt` in `D99760257` (which references this same MID and process), `updateOverflowInset` in `D104400233`; `removeViewAt`, `updateProps`, `updateLayout`, and `deleteView` were already graceful. The originally-reported `addViewAt` stack is therefore already fixed in trunk — crashes persist on release branch v201/v203 which predates `D99760257`.

`updateState` (`INSTRUCTION_UPDATE_STATE`) and `updatePadding` (`INSTRUCTION_UPDATE_PADDING`) were the two remaining throwing `getViewState` callers reachable from `IntBufferBatchMountItem.execute` — unfixed siblings of the same multi-site pattern and live/contributing crash sites for the same exception.

## Fix

Change `updateState` and `updatePadding` to use `getNullableViewState`; on null, log a `SURFACE_MOUNTING_MANAGER_MISSING_VIEWSTATE` soft exception and return early — identical to the established pattern in `addViewAt`, `updateOverflowInset`, `updateProps`, `updateLayout`, and `deleteView`. This is not a throw-downgrade of an invariant: `RetryableMountingLayerException` is an explicitly retryable transient signal, and this matches the canonical handling the RN team applies to every other batch mount method.

The non-batch callers (`sendAccessibilityEvent`, `setJSResponder`) are intentionally left unchanged — `sendAccessibilityEvent` is already protected by its own `try/catch (RetryableMountingLayerException)` in `SendAccessibilityEventMountItem.execute`.

## Changelog:

[Android] [Fixed] - Handle missing viewState gracefully in `SurfaceMountingManager.updateState` and `updatePadding` to avoid `RetryableMountingLayerException` crashes from the Fabric batch-mount path

Reviewed By: javache

Differential Revision: D107768754

fbshipit-source-id: 5861bcae5d598b6ffae48c32830d16323474d8bf
(cherry picked from commit 0e86a04)

* Fix RetryableMountingLayerException crash in updateOverflowInset (react#56762)

Summary:
Pull Request resolved: react#56762

Fix a crash in `SurfaceMountingManager.updateOverflowInset()` where `getViewState()` throws `RetryableMountingLayerException` when the view state for a tag is not found in the registry.

The crash occurs during batch mount item execution when an `updateOverflowInset` operation references a view tag that has been removed from the registry due to normal lifecycle race conditions. The surface is still active (not stopped), but the view has already been deleted.

The fix replaces `getViewState(reactTag)` (which throws) with `getNullableViewState(reactTag)` + null check + soft exception logging + early return. This matches the defensive pattern already used by peer methods in the same class: `updateLayout`, `addViewAt`, and `removeViewAt`.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D104400233

fbshipit-source-id: 678df406079da98c0c2180766c936b5f2bb9fcf7
(cherry picked from commit dabb434)

---------

Co-authored-by: Shubham Kumar Savita <kumarsavshubham@meta.com>
Co-authored-by: Pieter De Baets <pieterdb@meta.com>
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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants