Skip to content

Guard LogBox dialog dismiss against detached window#56765

Open
aroravarun wants to merge 1 commit into
facebook:mainfrom
aroravarun:export-D104391294
Open

Guard LogBox dialog dismiss against detached window#56765
aroravarun wants to merge 1 commit into
facebook:mainfrom
aroravarun:export-D104391294

Conversation

@aroravarun
Copy link
Copy Markdown

Summary:
LogBoxDialogSurfaceDelegate.hide() calls dialog.dismiss() whenever
dialog.isShowing is true, but the host Activity's window can be torn
down between the dispatch of LogBoxModule.hide() and the Handler
callback that runs hide(). When that race hits, Dialog.dismiss()
routes to WindowManagerImpl.removeViewImmediate, which throws
IllegalArgumentException: View ... not attached to window manager
and crashes the process.

Add an isAttachedToWindow check on the dialog's DecorView so the
dismiss is skipped once the host window is gone. The dialog reference
is still nulled and destroyContentView() still runs, so React state
is cleaned up correctly.

Changelog:
[Android][Fixed] - Avoid IllegalArgumentException when LogBox dismisses after the host Activity is destroyed

Differential Revision: D104391294

@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
Copy link
Copy Markdown

meta-codesync Bot commented May 11, 2026

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

Summary:
`LogBoxDialogSurfaceDelegate.hide()` calls `dialog.dismiss()` whenever
`dialog.isShowing` is true, but the host Activity's window can be torn
down between the dispatch of `LogBoxModule.hide()` and the Handler
callback that runs `hide()`. When that race hits, `Dialog.dismiss()`
routes to `WindowManagerImpl.removeViewImmediate`, which throws
`IllegalArgumentException: View ... not attached to window manager`
and crashes the process.

Add an `isAttachedToWindow` check on the dialog's DecorView so the
dismiss is skipped once the host window is gone. The dialog reference
is still nulled and `destroyContentView()` still runs, so React state
is cleaned up correctly.

Changelog:
[Android][Fixed] - Avoid IllegalArgumentException when LogBox dismisses after the host Activity is destroyed

Differential Revision: D104391294
@aroravarun aroravarun force-pushed the export-D104391294 branch from 16c561c to 7efe1c8 Compare May 11, 2026 12:04
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