Skip to content

Commit

Permalink
Fix crash for Modal not attached to window manager (#46758)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46758

There are some occurrencies where the Modal results not attached to the Window, perhaps when the app is backgrounded.

This trigger an exception `java.lang.IllegalArgumentException: View=DecorView@b9f88af[AdsManagerActivity] not attached to window manager`.\

This was fixed already but the conversion from Java to Kotlin missed a condition in the `||` clause. We are adding it back.

## Changelog
[Android][Fixed] - Fix crash for Modal not attached to window manager

## Facebook
The original fix is in this diff  D22264672 by mdvacca
Also see this post: https://fb.workplace.com/groups/rn.support/permalink/27047414764880449/

Reviewed By: cortinico

Differential Revision: D63700769

fbshipit-source-id: bc8a44868d5cacb8822e1646c2b7643682f45e1b
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Oct 1, 2024
1 parent 6d6dd99 commit eaa780d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public class ReactModalHostView(context: ThemedReactContext) :
val dialogWindow =
checkNotNull(dialog.window) { "dialog must have window when we call updateProperties" }
val currentActivity = getCurrentActivity()
if (currentActivity == null || currentActivity.isFinishing) {
if (currentActivity == null || currentActivity.isFinishing || !dialogWindow.isActive) {
// If the activity has disappeared, then we shouldn't update the window associated to the
// Dialog.
return
Expand Down

0 comments on commit eaa780d

Please sign in to comment.