Skip to content

Avoid crash dismissing a Modal whose Activity was destroyed - #59233

Closed
Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D125800172
Closed

Abbondanzo wants to merge 1 commit into
react:mainfrom
Abbondanzo:export-D125800172

Conversation

@Abbondanzo

Copy link
Copy Markdown
Contributor

Summary:
ReactModalHostView.dismiss() skipped Dialog.dismiss() only when the dialog's Activity was finishing. When that Activity is destroyed without finishing (for example relaunched on a configuration change while a Modal is open), its windows are already removed, so Dialog.dismiss() throws IllegalArgumentException: View=DecorView[...] not attached to window manager and crashes the app during teardown.

Also skip the dismiss when the Activity isDestroyed, and catch IllegalArgumentException around Dialog.dismiss(), matching the existing guard in updateProperties().

Changelog:
[Android][Fixed] - Fix crash when dismissing a Modal whose Activity has already been destroyed

Differential Revision: D125800172

Summary:
`ReactModalHostView.dismiss()` skipped `Dialog.dismiss()` only when the dialog's Activity was finishing. When that Activity is destroyed without finishing (for example relaunched on a configuration change while a Modal is open), its windows are already removed, so `Dialog.dismiss()` throws `IllegalArgumentException: View=DecorView[...] not attached to window manager` and crashes the app during teardown.

Also skip the dismiss when the Activity `isDestroyed`, and catch `IllegalArgumentException` around `Dialog.dismiss()`, matching the existing guard in `updateProperties()`.

Changelog:
[Android][Fixed] - Fix crash when dismissing a Modal whose Activity has already been destroyed

Differential Revision: D125800172
@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 Oct 20, 2026
@meta-codesync

meta-codesync Bot commented Oct 20, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot closed this in 7439937 Oct 21, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request has been merged in 7439937.

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