Skip to content

Commit 6fe2706

Browse files
alanleedevfacebook-github-bot
authored andcommitted
Guard statusBarShow/statusBarHide against detached decorView
Summary: `statusBarShow()` and `statusBarHide()` access the window's `decorView`, which throws `IllegalArgumentException` when the decorView is not attached to the window manager. This can happen for extra windows (dialogs/popups) whose decorView is detached independently of the host activity's lifecycle, or when status bar visibility is updated during teardown. Guard both functions with `if (!decorView.isAttachedToWindow) return` so the fix protects every caller at the source. The guard is a no-op during normal operation (the decorView is always attached) and only short-circuits during the teardown race. Changelog: [Android][Fixed] - Prevent `IllegalArgumentException` crash in `statusBarShow`/`statusBarHide` when the window decorView is detached Differential Revision: D107934787
1 parent 8bcfb3b commit 6fe2706

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ internal fun Window.setStatusBarStyle(style: String?) {
125125

126126
@Suppress("DEPRECATION")
127127
private fun Window.statusBarHide() {
128+
if (!decorView.isAttachedToWindow) return
128129
if (isEdgeToEdgeFeatureFlagOn) {
129130
WindowInsetsControllerCompat(this, decorView).run {
130131
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
@@ -144,6 +145,7 @@ private fun Window.statusBarHide() {
144145

145146
@Suppress("DEPRECATION")
146147
private fun Window.statusBarShow() {
148+
if (!decorView.isAttachedToWindow) return
147149
if (isEdgeToEdgeFeatureFlagOn) {
148150
WindowInsetsControllerCompat(this, decorView).run {
149151
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

0 commit comments

Comments
 (0)