Skip to content

Commit 732b848

Browse files
alanleedevmeta-codesync[bot]
authored andcommitted
Error: android_crash:java.lang.IllegalArgumentException:com.facebook.react.views.view.WindowUtilKt.s (facebook#57056)
Summary: Pull Request resolved: facebook#57056 Fixed the crash (IllegalArgumentException: View not attached to window manager in `StatusBarModule`). The root cause is a lifecycle race condition where `StatusBarModule.setHidden()` and `setStyle()` post runnables to the UI thread that modify window attributes, but the activity can be destroyed before the runnable executes. Added `activity.isFinishing || activity.isDestroyed` guard checks inside both UI thread runnables in `StatusBarModule.kt` to prevent modifying window attributes on a destroyed activity. Changelog: [Android][Fixed] - Prevent `IllegalArgumentException` crash in `StatusBarModule` when activity is destroyed before the UI thread runnable executes Reviewed By: javache, cortinico Differential Revision: D106202618 fbshipit-source-id: dc8eaf5698f19cb0192f1d115618ae0f8b2c472b
1 parent cb74b82 commit 732b848

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
151151
return
152152
}
153153
UiThreadUtil.runOnUiThread {
154+
if (activity.isFinishing || activity.isDestroyed) return@runOnUiThread
154155
activity.window?.setStatusBarVisibility(hidden)
155156
extraWindows.forEach { it.setStatusBarVisibility(hidden) }
156157
}
@@ -166,6 +167,7 @@ internal class StatusBarModule(reactContext: ReactApplicationContext?) :
166167
return
167168
}
168169
UiThreadUtil.runOnUiThread {
170+
if (activity.isFinishing || activity.isDestroyed) return@runOnUiThread
169171
activity.window?.setStatusBarStyle(style)
170172
extraWindows.forEach { it.setStatusBarStyle(style) }
171173
}

0 commit comments

Comments
 (0)