wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Multiple crashes on Android 11/12 in 7.26.0 and 7.25.1 #7501

Closed stratus1011 closed 2 years ago

stratus1011 commented 2 years ago

🐛 Bug Report

We are seeing crashes in 7.26.0 and 7.25.1 on Android 11/12 devices frequently whenever we have modals or bottomsheets showing. It could be happening in earlier versions, but these are the ones we've tracked. Almost all instances of the crash seem to happen at some point when the Activity is going in to the background on onPause or a similar lifecycle event. The stacktrace is the same regardless of the specific background "event". I think it may have to do with code changes for Android API 30 done in this change: https://github.com/wix/react-native-navigation/commit/eae58312ce997ed580163e2f1d5cb6c3ea1ec086

Stacktrace for 7.26.0:

java.lang.NullPointerException: The insets controller is null. The root view might have been detached from its window
        at androidx.core.util.Preconditions.checkNotNull(Preconditions.java:154)
        at androidx.core.view.WindowInsetsControllerCompat$Impl30.<init>(WindowInsetsControllerCompat.java:620)
        at androidx.core.view.WindowInsetsControllerCompat.<init>(WindowInsetsControllerCompat.java:103)
        at androidx.core.view.WindowInsetsControllerCompat.<init>(WindowInsetsControllerCompat.java:120)
        at com.reactnativenavigation.utils.SystemUiUtils.showStatusBar(SystemUiUtils.kt:152)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.setStatusBarVisible(Presenter.java:129)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.applyStatusBarOptions(Presenter.java:112)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.onViewBroughtToFront(Presenter.java:64)
        at com.reactnativenavigation.viewcontrollers.child.ChildController.onViewBroughtToFront(ChildController.java:70)
        at com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry.onViewDisappear(ChildControllersRegistry.java:17)
        at com.reactnativenavigation.viewcontrollers.child.ChildController.onViewDisappear(ChildController.java:66)
        at com.reactnativenavigation.viewcontrollers.component.ComponentViewController.onViewDisappear(ComponentViewController.java:98)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.navigator.Navigator.onHostPause(Navigator.java:281)
        at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0$NavigationModule$1(NavigationModule.java:62)
        at com.reactnativenavigation.react.-$$Lambda$NavigationModule$1$188Rw-Gn_-JcbOeFEeH40BTzx_c.run(Unknown:2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8663)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

In 7.25.1 we were getting a similar error, but it had a little bit more to the stacktrace:

java.lang.RuntimeException: Unable to pause activity {.MainActivity}: java.lang.NullPointerException: The insets controller is null. The root view might have been detached from its window
        at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4743)
        at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4694)
        at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4645)
        at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7664)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Caused by: java.lang.NullPointerException: The insets controller is null. The root view might have been detached from its window
        at androidx.core.util.Preconditions.checkNotNull(Preconditions.java:154)
        at androidx.core.view.WindowInsetsControllerCompat$Impl30.<init>(WindowInsetsControllerCompat.java:620)
        at androidx.core.view.WindowInsetsControllerCompat.<init>(WindowInsetsControllerCompat.java:103)
        at androidx.core.view.WindowInsetsControllerCompat.<init>(WindowInsetsControllerCompat.java:120)
        at com.reactnativenavigation.utils.SystemUiUtils.showStatusBar(SystemUiUtils.kt:152)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.setStatusBarVisible(Presenter.java:129)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.applyStatusBarOptions(Presenter.java:112)
        at com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter.onViewBroughtToFront(Presenter.java:64)
        at com.reactnativenavigation.viewcontrollers.child.ChildController.onViewBroughtToFront(ChildController.java:70)
        at com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry.onViewDisappear(ChildControllersRegistry.java:17)
        at com.reactnativenavigation.viewcontrollers.child.ChildController.onViewDisappear(ChildController.java:66)
        at com.reactnativenavigation.viewcontrollers.component.ComponentViewController.onViewDisappear(ComponentViewController.java:91)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.parent.ParentController.onViewDisappear(ParentController.java:58)
        at com.reactnativenavigation.viewcontrollers.navigator.Navigator.onHostPause(Navigator.java:281)
        at com.reactnativenavigation.react.NavigationModule$1.onHostPause(NavigationModule.java:62)
        at com.facebook.react.bridge.ReactContext.onHostPause(ReactContext.java:290)
        at com.facebook.react.ReactInstanceManager.moveToBeforeResumeLifecycleState(ReactInstanceManager.java:754)
        at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:549)
        at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:571)
        at com.reactnativenavigation.react.NavigationReactInitializer.onActivityPaused(NavigationReactInitializer.java:40)
        at com.reactnativenavigation.react.ReactGateway.onActivityPaused(ReactGateway.java:52)
        at com.reactnativenavigation.NavigationActivity.onPause(NavigationActivity.java:81)
        at android.app.Activity.performPause(Activity.java:8168)
        at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1510)
        at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4733)
        at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4694)
        at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4645)
        at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:46)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7664)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

I've done my best to reproduce it on a Pixel 6, but have been unsuccessful.

Expected behavior

Crashes should not happen on modals and bottom sheets.

Actual Behavior

We are seeing crashes in 7.26.0 and 7.25.1 on Android 11/12 devices frequently whenever we have modals or bottomsheets showing.

Your Environment

Reproducible Demo

(Paste the link to an example repo and exact instructions to reproduce the issue.)

Are you willing to resolve this issue by submitting a Pull Request?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

stale[bot] commented 2 years ago

The issue has been closed for inactivity.