Skip to content

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

Closed
shubhamksavita wants to merge 1 commit into
mainfrom
export-D107768754
Closed

Handle missing viewState gracefully in SurfaceMountingManager.updateState and updatePadding (#57181)#57181
shubhamksavita wants to merge 1 commit into
mainfrom
export-D107768754

Conversation

@shubhamksavita

@shubhamksavita shubhamksavita commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary:

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

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

@meta-codesync meta-codesync Bot force-pushed the export-D107768754 branch from ffce5d0 to a804982 Compare June 11, 2026 23:23
@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 Jun 11, 2026
@meta-codesync

meta-codesync Bot commented Jun 11, 2026

Copy link
Copy Markdown

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

…tate and updatePadding (#57181)

Summary:

## 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
@meta-codesync meta-codesync Bot changed the title Handle missing viewState gracefully in SurfaceMountingManager.updateState and updatePadding Handle missing viewState gracefully in SurfaceMountingManager.updateState and updatePadding (#57181) Jun 11, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D107768754 branch from a804982 to cecd11e Compare June 11, 2026 23:41
@shubhamksavita shubhamksavita requested a review from javache June 11, 2026 23:50
@meta-codesync meta-codesync Bot closed this in 0e86a04 Jun 12, 2026
@meta-codesync

meta-codesync Bot commented Jun 12, 2026

Copy link
Copy Markdown

This pull request has been merged in 0e86a04.

@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 12, 2026
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. 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.

1 participant