React-native-screens: 2.4.0 [Android] Crash: No view found for id 0x531 (unknown) for fragment ScreenFragment

Created on 13 Apr 2020  Â·  30Comments  Â·  Source: software-mansion/react-native-screens

54 was closed, I'm creating a new issue for the following dependencies:

"react-native-screens": "^2.4.0",
"react-native-gesture-handler": "^1.5.6",
"react-native": "0.61.5",
"react-navigation": "^4.3.7",
"react-navigation-stack": "^2.2.3",
"react-navigation-tabs": "^2.8.2", 

Raw Exception:

java.lang.RuntimeException Unable to pause activity {com.ovo.energy/com.ovo.energy.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0x531 (unknown) for fragment ScreenFragment{d5e11cd} (1dfe2ba5-2b95-4f48-ab7a-947dde476854) id=0x531} 
    ActivityThread.java:3981 android.app.ActivityThread.performPauseActivityIfNeeded
    ActivityThread.java:3947 android.app.ActivityThread.performPauseActivity
    ActivityThread.java:3921 android.app.ActivityThread.performPauseActivity
    ActivityThread.java:4739 android.app.ActivityThread.handleRelaunchActivity
    Unknown android.app.ActivityThread.-wrap18
    ActivityThread.java:1604 android.app.ActivityThread$H.handleMessage
    Handler.java:105 android.os.Handler.dispatchMessage
    Looper.java:251 android.os.Looper.loop
    ActivityThread.java:6572 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    Zygote.java:240 com.android.internal.os.Zygote$MethodAndArgsCaller.run
    ZygoteInit.java:767 com.android.internal.os.ZygoteInit.main

Caused by: java.lang.IllegalArgumentException No view found for id 0x531 (unknown) for fragment ScreenFragment{d5e11cd} (1dfe2ba5-2b95-4f48-ab7a-947dde476854) id=0x531} 
    FragmentStateManager.java:315 androidx.fragment.app.FragmentStateManager.createView
    FragmentManager.java:1187 androidx.fragment.app.FragmentManager.moveToState
    FragmentManager.java:1356 androidx.fragment.app.FragmentManager.moveToState
    FragmentManager.java:1434 androidx.fragment.app.FragmentManager.moveFragmentToExpectedState
    FragmentManager.java:1497 androidx.fragment.app.FragmentManager.moveToState
    FragmentManager.java:2625 androidx.fragment.app.FragmentManager.dispatchStateChange
    FragmentManager.java:2593 androidx.fragment.app.FragmentManager.dispatchPause
    FragmentController.java:280 androidx.fragment.app.FragmentController.dispatchPause
    FragmentActivity.java:419 androidx.fragment.app.FragmentActivity.onPause
    ReactActivity.java:49 com.facebook.react.ReactActivity.onPause
    Activity.java:7115 android.app.Activity.performPause
    Instrumentation.java:1408 android.app.Instrumentation.callActivityOnPause
    ActivityThread.java:3970 android.app.ActivityThread.performPauseActivityIfNeeded
    ActivityThread.java:3947 android.app.ActivityThread.performPauseActivity
    ActivityThread.java:3921 android.app.ActivityThread.performPauseActivity
    ActivityThread.java:4739 android.app.ActivityThread.handleRelaunchActivity
    Unknown android.app.ActivityThread.-wrap18
    ActivityThread.java:1604 android.app.ActivityThread$H.handleMessage
    Handler.java:105 android.os.Handler.dispatchMessage
    Looper.java:251 android.os.Looper.loop
    ActivityThread.java:6572 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    Zygote.java:240 com.android.internal.os.Zygote$MethodAndArgsCaller.run
    ZygoteInit.java:767 com.android.internal.os.ZygoteInit.main

MainActivity.java:

package com.app;

import com.facebook.react.ReactActivity;
import android.os.Bundle; // <- RNBootSplash
import com.zoontek.rnbootsplash.RNBootSplash; // RNBootSplash

import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  @Override
  protected String getMainComponentName() {
    return "App";
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
    RNBootSplash.show(R.drawable.bootsplash, MainActivity.this); // <- display the "bootsplash" xml view over our MainActivity
   }

   @Override
   protected ReactActivityDelegate createReactActivityDelegate() {
     return new ReactActivityDelegate(this, getMainComponentName()) {
       @Override
       protected ReactRootView createRootView() {
        return new RNGestureHandlerEnabledRootView(MainActivity.this);
       }
     };
   }
}

enableScreens() is called in the same way as https://github.com/software-mansion/react-native-screens/blob/master/Example/App.js#L16

Additional information that might be helpful:

Android Versions:

OS versions | OS | Events | % Events
-- | -- | -- | --
10about 1 hour ago – 3 days ago | android | 117 | 54.2%
9about 1 hour ago – 3 days ago | android | 64 | 29.6%
8.0.0about 27 minutes ago – 3 days ago | android | 16 | 7.4%
7.0about 1 hour ago – 2 days ago | android | 9 | 4.2%
8.1.0about 1 day ago – 2 days ago | android | 8 | 3.7%
7.1.1about 2 days ago | android | 2 | 0.9%

Manufacturers:

Manufacturers | Events | % Events
-- | -- | --
samsungabout 1 hour ago – 3 days ago | 133 | 61.6%
HUAWEIabout 1 hour ago – 3 days ago | 31 | 14.4%
Googleabout 1 hour ago – 2 days ago | 17 | 7.9%
Sonyabout 28 minutes ago – 3 days ago | 14 | 6.5%
OnePlusabout 1 hour ago – 18 hours ago | 11 | 5.1%
motorolaabout 15 hours ago – 2 days ago | 4 | 1.9%
Droiabout 2 days ago | 2 | 0.9%
LGEabout 2 days ago | 2 | 0.9%
Xiaomiabout 2 days ago | 2 | 0.9%
 

Models

Models | Manufacturer | Events | % Events
-- | -- | -- | --
SM-G960Fabout 9 hours ago – 3 days ago | samsung | 30 | 13.9%
SM-G973Fabout 3 hours ago – 2 days ago | samsung | 14 | 6.5%
SM-G975Fabout 12 hours ago – 3 days ago | samsung | 12 | 5.6%
ONEPLUS A5010about 1 hour ago – 14 hours ago | OnePlus | 8 | 3.7%
SM-A505FNabout 2 days ago – 3 days ago | samsung | 7 | 3.2%
CLT-L09about 13 hours ago – 3 days ago | HUAWEI | 6 | 2.8%
Pixel 3aabout 1 hour ago – 1 day ago | Google | 6 | 2.8%
SM-A530Fabout 1 day ago – 2 days ago | samsung | 6 | 2.8%
SM-G965Fabout 2 hours ago – 3 days ago | samsung | 6 | 2.8%
FIG-LX1about 14 hours ago – 2 days ago | HUAWEI | 5 | 2.3%
Pixel 3about 1 day ago – 2 days ago | Google | 5 | 2.3%
ELE-L09about 1 day ago – 3 days ago | HUAWEI | 4 | 1.9%
F5321about 3 hours ago – 3 days ago | Sony | 4 | 1.9%
FRD-L09about 1 hour ago – 1 day ago | HUAWEI | 4 | 1.9%
J8110about 22 hours ago – 2 days ago | Sony | 4 | 1.9%
SM-A705FNabout 1 day ago – 2 days ago | samsung | 4 | 1.9%
SM-G930Fabout 14 hours ago – 2 days ago | samsung | 4 | 1.9%
SM-G970Fabout 19 hours ago – 1 day ago | samsung | 4 | 1.9%
SM-J530Fabout 2 hours ago – 1 day ago | samsung | 4 | 1.9%
SM-N960Fabout 2 days ago | samsung | 4 | 1.9%
SM-N976Babout 15 hours ago – 1 day ago | samsung | 4 | 1.9%
ONEPLUS A5000about 17 hours ago – 18 hours ago | OnePlus | 3 | 1.4%
SM-G950Fabout 21 hours ago | samsung | 3 | 1.4%
SM-M307FNabout 1 day ago | samsung | 3 | 1.4%
SM-T510about 1 hour ago | samsung | 3 | 1.4%
ELE-L29about 2 days ago | HUAWEI | 2 | 0.9%
F8331about 28 minutes ago – 29 minutes ago | Sony | 2 | 0.9%
H8416about 1 day ago | Sony | 2 | 0.9%
HRY-LX1about 2 days ago | HUAWEI | 2 | 0.9%
J8210about 1 day ago | Sony | 2 | 0.9%
LYA-L09about 3 days ago | HUAWEI | 2 | 0.9%
Moto G (5S) Plusabout 2 days ago | motorola | 2 | 0.9%
Nexus 5Xabout 2 days ago | LGE | 2 | 0.9%
Nexus 6Pabout 1 day ago | Huawei | 2 | 0.9%
One Maxabout 2 days ago | Droi | 2 | 0.9%
Pixel 2 XLabout 1 day ago | Google | 2 | 0.9%
Pixel 3 XLabout 2 days ago | Google | 2 | 0.9%
Pixel 3a XLabout 14 hours ago | Google | 2 | 0.9%
Redmi Note 8 Proabout 2 days ago | Xiaomi | 2 | 0.9%
SM-A105FNabout 4 hours ago | samsung | 2 | 0.9%
SM-A320FLabout 12 hours ago | samsung | 2 | 0.9%
SM-A405FNabout 2 days ago | samsung | 2 | 0.9%
SM-A520Fabout 2 days ago | samsung | 2 | 0.9%
SM-A600FNabout 1 day ago | samsung | 2 | 0.9%
SM-A750FNabout 3 days ago | samsung | 2 | 0.9%
SM-G925Fabout 2 days ago | samsung | 2 | 0.9%
SM-G928Fabout 2 days ago | samsung | 2 | 0.9%
SM-G935Fabout 1 day ago – 2 days ago | samsung | 2 | 0.9%
SM-G986Babout 2 days ago | samsung | 2 | 0.9%
SM-J510FNabout 2 days ago | samsung | 2 | 0.9%
SM-T590about 16 hours ago | samsung | 2 | 0.9%
SNE-LX1about 2 days ago | HUAWEI | 2 | 0.9%
VOG-L09about 1 day ago | HUAWEI | 2 | 0.9%
motorola oneabout 15 hours ago | motorola | 2 | 0.9%
SM-T715about 18 hours ago | samsung | 1 | 0.5%

--

Thanks for all your help in advance!

Android needs repro

Most helpful comment

We're seeing the same issue in production. Working to find a device and replication steps.

All 30 comments

Hey @henrymoulton, thank you for reporting. Is this crash something you can reproduce locally, or just traces collected from the app running in production?

Thanks for responding @kmagiera, this was collected in production.

We’ve since turned Screens off and not had this crash.

Just got a similar stack trace on production today as well:

java.lang.IllegalArgumentException No view found for id 0x109d (unknown) for fragment ScreenFragment{d744b97} (8af2b140-99e8-4855-a81a-f3d52a32cdeb) id=0x109d} 
    FragmentStateManager.java:315 androidx.fragment.app.FragmentStateManager.createView
    FragmentManager.java:1187 androidx.fragment.app.FragmentManager.moveToState
    FragmentManager.java:2224 androidx.fragment.app.FragmentManager.addAddedFragments
    FragmentManager.java:1997 androidx.fragment.app.FragmentManager.executeOpsTogether
    FragmentManager.java:1953 androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute
    FragmentManager.java:1849 androidx.fragment.app.FragmentManager.execPendingActions
    FragmentManager.java:489 androidx.fragment.app.FragmentManager.executePendingTransactions
    ScreenContainer.java:227 com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow
    View.java:17611 android.view.View.dispatchDetachedFromWindow
    ViewGroup.java:3729 android.view.ViewGroup.dispatchDetachedFromWindow
    ViewGroup.java:5494 android.view.ViewGroup.removeAllViewsInLayout
    ViewGroup.java:5440 android.view.ViewGroup.removeAllViews
    ReactViewManager.java:399 com.facebook.react.views.view.ReactViewManager.removeAllViews
    ReactViewManager.java:37 com.facebook.react.views.view.ReactViewManager.removeAllViews
    NativeViewHierarchyManager.java:620 com.facebook.react.uimanager.NativeViewHierarchyManager.dropView
    NativeViewHierarchyManager.java:617 com.facebook.react.uimanager.NativeViewHierarchyManager.dropView
    NativeViewHierarchyManager.java:617 com.facebook.react.uimanager.NativeViewHierarchyManager.dropView
    NativeViewHierarchyManager.java:617 com.facebook.react.uimanager.NativeViewHierarchyManager.dropView
    NativeViewHierarchyManager.java:494 com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren
    UIViewOperationQueue.java:205 com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute
    UIViewOperationQueue.java:779 com.facebook.react.uimanager.UIViewOperationQueue$1.run
    UIViewOperationQueue.java:888 com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches
    UIViewOperationQueue.java:42 com.facebook.react.uimanager.UIViewOperationQueue.access$2200
    UIViewOperationQueue.java:948 com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded
    GuardedFrameCallback.java:28 com.facebook.react.uimanager.GuardedFrameCallback.doFrame
    ReactChoreographer.java:174 com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame
    ChoreographerCompat.java:84 com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame
    Choreographer.java:979 android.view.Choreographer$CallbackRecord.run
    Choreographer.java:790 android.view.Choreographer.doCallbacks
    Choreographer.java:718 android.view.Choreographer.doFrame
    Choreographer.java:967 android.view.Choreographer$FrameDisplayEventReceiver.run
    Handler.java:808 android.os.Handler.handleCallback
    Handler.java:101 android.os.Handler.dispatchMessage
    Looper.java:166 android.os.Looper.loop
    ActivityThread.java:7523 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    Zygote.java:245 com.android.internal.os.Zygote$MethodAndArgsCaller.run
    ZygoteInit.java:921 com.android.internal.os.ZygoteInit.main

It's slightly different from what @henrymoulton has attached as mine clearly has an rnscreens package in the stack trace. I only had one case on HUAWEI PRA-LX1 Android 8.0.

"react-native-screens": "^2.4.0",
"react-native-gesture-handler": "^1.5.3",
"react-native": "0.61.5",
"react-navigation": "^4.3.7",
"react-navigation-stack": "^2.3.11",
"react-navigation-tabs": "^2.8.11", 

We're seeing the same issue in production. Working to find a device and replication steps.

We have the same issue in production. According to logs in Crashlytics we know that it happens on screens with webview.
We have already added workaround for webviews with renderToHardwareTextureAndroid, and maybe it's related to crashes?

@ardentum if you are talking about https://github.com/software-mansion/react-native-screens/issues/105#issuecomment-669891558 as a workaround, it only works on native-stack since normal stack navigator does not fire the same events so it won't work there. Could you try and add this change: https://github.com/software-mansion/react-native-screens/pull/607 if you are using stack navigator and see if fixes the issue?

@WoLewicki Yes, I mentioned your comment for #105. We use stack, and there was a lot of crashes on screens with webview, but your workaround somehow helped us. Maybe just for some cases. Thank you!

Hmm Ok, @adkenyon @henrymoulton @akontaroudis can you elaborate on if this crash happens only on screens with WebView?

Looking at our error logs, the large majority of crashes are on app start, of the ones not happening on app start, I don't see any correlation with screens that have web views.

Not sure if related to this issue 100%, but I have noticed an increasing amount of crashes also in our prod release for ScreenFragment. I'm currently using v2.9.0, but also React Navigation v5 + React Native v0.62.2.

Here's the last step of the stacktrace:

Caused by: java.lang.IllegalStateException: 
  at com.swmansion.rnscreens.ScreenFragment.<init> (ScreenFragment.java:38)
  at java.lang.reflect.Constructor.newInstance0 (Constructor.java)
  at java.lang.reflect.Constructor.newInstance (Constructor.java:343)
  at androidx.fragment.app.Fragment.instantiate (Fragment.java:548)
  at androidx.fragment.app.FragmentContainer.instantiate (FragmentContainer.java:57)
  at androidx.fragment.app.FragmentManager$3.instantiate (FragmentManager.java:390)
  at androidx.fragment.app.FragmentStateManager.<init> (FragmentStateManager.java:74)
  at androidx.fragment.app.FragmentManager.restoreSaveState (FragmentManager.java:2454)
  at androidx.fragment.app.FragmentController.restoreSaveState (FragmentController.java:196)
  at androidx.fragment.app.FragmentActivity.onCreate (FragmentActivity.java:287)
  at androidx.appcompat.app.AppCompatActivity.onCreate (AppCompatActivity.java:106)
  at com.facebook.react.ReactActivity.onCreate (ReactActivity.java:44)
  at com.kankkunen.MainActivity.onCreate (MainActivity.java:28)
  at android.app.Activity.performCreate (Activity.java:8086)
  at android.app.Activity.performCreate (Activity.java:8074)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1313)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3755)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3961)
  at android.app.ActivityThread.handleRelaunchActivityInner (ActivityThread.java:5930)
  at android.app.ActivityThread.handleRelaunchActivity (ActivityThread.java:5820)
  at android.app.servertransaction.ActivityRelaunchItem.execute (ActivityRelaunchItem.java:69)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:149)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:103)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2386)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:213)
  at android.app.ActivityThread.main (ActivityThread.java:8178)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)

If any other info is needed, I'm happy to help 🙂

@pedpess do you pass null to onCreate the same way it is shown in the https://github.com/software-mansion/react-native-screens/issues/463#issue-598797663?

Hi, I am getting this error in production build of our app,:
react-native screens version is "2.10.1",
can anybody tell me why this could be happening
Fatal Exception: java.lang.IllegalArgumentException: No view found for id 0x5e9 (unknown) for fragment g{5f69ea9} (48fffc1a-4692-4b67-897b-b59d9ee691b1) id=0x5e9}
at androidx.fragment.app.FragmentStateManager.a(FragmentStateManager.java:131)
at androidx.fragment.app.FragmentManager.a(FragmentManager.java:237)
at androidx.fragment.app.FragmentManager.a(FragmentManager.java:37)
at androidx.fragment.app.FragmentManager.b(FragmentManager.java:130)
at androidx.fragment.app.FragmentManager.c(FragmentManager.java:94)
at androidx.fragment.app.FragmentManager.c(FragmentManager.java:21)
at androidx.fragment.app.FragmentManager.n(FragmentManager.java:1)
at com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow(ScreenContainer.java:15)
at android.view.View.dispatchDetachedFromWindow(View.java:17612)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3733)
at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5618)
at android.view.ViewGroup.removeAllViews(ViewGroup.java:5564)
at com.facebook.react.views.view.ReactClippingViewManager.removeAllViews(ReactClippingViewManager.java:13)
at com.facebook.react.views.view.ReactClippingViewManager.removeAllViews(ReactClippingViewManager.java:2)
at com.facebook.react.uimanager.NativeViewHierarchyManager.a(NativeViewHierarchyManager.java:121)
at com.facebook.react.uimanager.NativeViewHierarchyManager.a(NativeViewHierarchyManager.java:115)
at com.facebook.react.uimanager.NativeViewHierarchyManager.a(NativeViewHierarchyManager.java:115)
at com.facebook.react.uimanager.NativeViewHierarchyManager.a(NativeViewHierarchyManager.java:307)
at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:16)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:72)
at com.facebook.react.uimanager.UIViewOperationQueue.i(UIViewOperationQueue.java:53)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2400(UIViewOperationQueue.java)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:31)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:46)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:2)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:984)
at android.view.Choreographer.doCallbacks(Choreographer.java:798)
at android.view.Choreographer.doFrame(Choreographer.java:727)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:972)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6754)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)

@WoLewicki Yes I do, first I initiate the SplashScreen.show(this, true) from react-native-splash-screen lib in my onCreate

After that, I invoke super.onCreate(null). Do you think that passing the argument from Bundle savedInstanceState e.g. super.onCreate(savedInstanceState) would be the recommended way again?

@pedpess no, it is not recommended, just thought maybe you didn't do it since from the stack trace it seems like the crash happens in onCreate, so it seems weird. Maybe there is a problem with some of the fragments not being removed properly. Do you use native-stack? Also, would it be possible for you to make a repo on which I could reproduce this crash? Since no one managed to do it yet afaik and it would be super helpful.

@WoLewicki Sorry for the delay. I think we don't use native-stack anymore as we recently migrated to react-navigation v5. We are using @react-navigation/compat, drawer, native and stack. Unfortunately, I haven't managed to reproduce the issue myself, but if you have ideas on how to force this issue to happen I could make a repo for you and share it here. From the data I got from Google Play, it mostly happens with the latest Android versions 10 and 9.

These are the top 10 devices with this crash:
Screenshot 2020-09-05 at 13 06 18

@pedpess based on the stack trace, it looks like you are not passing null since the onCreate's argument is passed up to FragmentActivity.onCreate() and there is a check for a null in the passed argument, which, based on your stack trace, is not null since the restoreSaveState() is called. I attach screen of this below. Are you sure the null was passed there when the stack trace was collected? Maybe there is a different option for these methods to be called, but I cannot think of any.
image

@WoLewicki good news 🙂 the issue is gone adding the super.onCreate(null). False alarm from my side, sorry about that. The problem was that we still had quite many users with the older version of the app that was with this crash. I can't force update them for now, but I will ask them to update the app manually if it shows up 👍

@akontaroudis @ANIBIT14 can you provide a repo with the configuration needed to reproduce the issue? Your crashes are caused by onDetachedFromWindow method, so it is not related to passing null to onCreate, so the reproduction of this crash would really help us to remove the problem. Also, @adkenyon, if your crash is similar, could you try and submit a repro?

I have been facing the same issue. Not able to reproduce this, but seeing a number of crashes on Crashlytics.
Here are the dependencies I am using -
I am passing null to super.onCreate

"@react-navigation/drawer": "5.1.1"
"@react-navigation/native": "5.0.9"
"react-native": "0.63.0"
"react-native-screens": "2.10.1"

Stacktrace -

Fatal Exception: java.lang.RuntimeException: Unable to pause activity {*.*.*/*.*.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0xa9 (unknown) for fragment g{c2f6631} (3d710c8a-fa3f-42a1-a496-69d9773638ef) id=0xa9}
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4078)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4033)
       at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:4817)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4756)
       at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:55)
       at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:4806)
       at android.app.ActivityThread.access$3300(ActivityThread.java:200)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1841)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:201)
       at android.app.ActivityThread.main(ActivityThread.java:6823)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Caused by java.lang.IllegalArgumentException: No view found for id 0xa9 (unknown) for fragment g{c2f6631} (3d710c8a-fa3f-42a1-a496-69d9773638ef) id=0xa9}
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:18)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:18)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1)
       at androidx.fragment.app.FragmentManager.W(FragmentManager.java:47)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:9)
       at androidx.fragment.app.FragmentManager.dispatchPause(FragmentManager.java:2)
       at androidx.fragment.app.FragmentController.dispatchPause(FragmentController.java:2)
       at androidx.fragment.app.FragmentActivity.onPause(FragmentActivity.java:2)
       at com.pgapps.MainActivity.onPause(MainActivity.java)
       at android.app.Activity.performPause(Activity.java:7444)
       at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1466)
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4068)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4033)
       at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:4817)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4756)
       at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:55)
       at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:4806)
       at android.app.ActivityThread.access$3300(ActivityThread.java:200)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1841)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:201)
       at android.app.ActivityThread.main(ActivityThread.java:6823)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Device coverage -
image

@WoLewicki Please let me know if any other info is required to help you debug.

@anirudhagarwal365 (and others), if you want to help, please provide some details of when the crashes happen in the lifecycle of the app. It looks like they happen only when pausing/resuming the activity, so if you would try to reproduce it to provide a repo, this is the direction I would go. You can try to make the app go into the background and then back. The important information would be if it happens when there is no navigation happening, or maybe only if e.g. you switched the screen and immediately paused the activity. You can also try https://github.com/software-mansion/react-native-screens/issues/556#issuecomment-656044339 and see if it helps.

@WoLewicki We tried out the fix you pointed in our production app. This seemed to have reduced the number of crashes, but recently we faced another crash at here.

The stacktrace is -

Caused by java.lang.IllegalStateException: FragmentManager is already executing transactions
       at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:4)
       at androidx.fragment.app.FragmentManager.generateOpsForPendingActions(FragmentManager.java)
       at androidx.fragment.app.FragmentManager.executePendingTransactions(FragmentManager.java:1)
       at com.swmansion.rnscreens.ScreenContainer.onUpdate(ScreenContainer.java:1)
       at com.swmansion.rnscreens.ScreenContainer.updateIfNeeded(ScreenContainer.java:1)
       at com.swmansion.rnscreens.ScreenContainer.setFragmentManager(ScreenContainer.java:2)
       at com.swmansion.rnscreens.ScreenContainer.setupFragmentManager(ScreenContainer.java:3)
       at android.view.View.dispatchAttachedToWindow(View.java:19723)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3455)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3462)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3462)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3462)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3462)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3462)
       at android.view.ViewGroup.addViewInner(ViewGroup.java:5174)
       at android.view.ViewGroup.addView(ViewGroup.java:4960)
       at android.view.ViewGroup.addView(ViewGroup.java:4900)
       at com.facebook.react.uimanager.ViewGroupManager.addView(ViewGroupManager.java)
       at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:5)
       at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:5)
       at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:4)
       at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:53)
       at com.facebook.react.uimanager.UIViewOperationQueue.pauseFrameCallback(UIViewOperationQueue.java:2)
       at com.facebook.react.uimanager.UIImplementation.onHostPause(UIImplementation.java:2)
       at com.facebook.react.uimanager.UIManagerModule.onHostPause(UIManagerModule.java:2)
       at com.facebook.react.bridge.ReactContext.onHostPause(ReactContext.java:27)
       at com.facebook.react.ReactInstanceManager.moveToBeforeResumeLifecycleState(ReactInstanceManager.java:1)
       at com.facebook.react.ReactInstanceManager.onHostPause(ReactInstanceManager.java:54)
       at com.facebook.react.ReactDelegate.onHostPause(ReactDelegate.java:4)
       at com.facebook.react.ReactFragment.onPause(ReactFragment.java:4)
       at androidx.fragment.app.Fragment.performPause(Fragment.java:4)
       at androidx.fragment.app.FragmentStateManager.pause(FragmentStateManager.java:23)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:23)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1)
       at androidx.fragment.app.FragmentManager.W(FragmentManager.java:47)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:9)
       at androidx.fragment.app.FragmentManager.dispatchPause(FragmentManager.java:2)
       at androidx.fragment.app.FragmentController.dispatchPause(FragmentController.java:2)
       at androidx.fragment.app.FragmentActivity.onPause(FragmentActivity.java:2)
       at com.pgapps.MainActivity.onPause(MainActivity.java)
       at android.app.Activity.performPause(Activity.java:8001)
       at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1667)
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4621)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4582)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4534)
       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:2131)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7707)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Actually the above PR actually fixes this issue(related to onPause). The stacktrace shared above is for another crash.
I suspected that the above crash could be affect of the changes made, but on careful examination of crashes on app, I found out that crash on onUpdate method has been happening throughout.

@WoLewicki Any insights on the above mentioned crash?

Wanted to check with you, since we have moved to sync implementation of committing fragments, would it be safe to remove executePendingTransactions() from onUpdate method in ScreenContainer class?

I cannot help you much because I need a repo with a reproduction to work on it and see how the behaviors change. You can try and remove it, maybe it is forbidden when there are only synchronous transitions. It would be best if you could make a repo in which any of these crashes can be seen, otherwise, there is very little I can do.

Any workaround about this?

What a bummer!
Had to uninstall react-native-screens because of this issue :/
Tried using the latest version 3.0.0 on rn 0.63.3.
The crash happens almost every time when I navigate to a stack screen which was the first screen of the app in react-navigation from a screen that is inside a tab navigator (Usually when someone presses logout)
Also, the crash only happens on the play store release build and not on debug (Could it be a pro-guard issue?)

java.lang.IllegalArgumentException: No view found for id 0x215 (unknown) for fragment ScreenFragment{8fa1bf3} (e241da77-f232-46ca-ba62-2ed17e002540) id=0x215} at androidx.fragment.app.FragmentStateManager.a(FragmentStateManager.java:131)

So I think I found where the issue is
It got fixed when I set detachInactiveScreens={false} on the tab navigator but then the tab navigator starts behaving weirdly and screens stop changing on changing the tabs.

@shubhamverma27 can you provide a test example in TestsExample project (https://github.com/software-mansion/react-native-screens/tree/master/TestsExample) with minimal configuration needed to reproduce the issue? There still isn't one for this issue so there is not much we can do about it. Setting detachInactiveScreens={false} is not a solution since it just disables usage of react-native-screens for the navigator.

Same here. Can't reproduce on debug, only release apk

I'm having the same issue in release. The app crashes on launch.

java.lang.IllegalArgumentException: No view found for id 0x131 (unknown) for fragment ScreenFragment{20c7be9} (74966ce8-d3a7-416e-8c77-895b1f4ea015) id=0x131}
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:315)
    at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
    at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
    at androidx.fragment.app.FragmentManager.executePendingTransactions(FragmentManager.java:489)
    at com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow(ScreenContainer.java:290)
    at android.view.View.dispatchDetachedFromWindow(View.java:20178)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3858)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3850)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3850)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3850)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3850)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3850)
    at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5687)
    at android.view.ViewGroup.removeAllViews(ViewGroup.java:5633)
    at com.facebook.react.ReactInstanceManager.clearReactRoot(ReactInstanceManager.java:791)
    at com.facebook.react.ReactInstanceManager.tearDownReactContext(ReactInstanceManager.java:1200)
    at com.facebook.react.ReactInstanceManager.runCreateReactContextOnNewThread(ReactInstanceManager.java:986)
    at com.facebook.react.ReactInstanceManager.recreateReactContextInBackground(ReactInstanceManager.java:973)
    at com.facebook.react.ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader(ReactInstanceManager.java:448)
    at com.facebook.react.ReactInstanceManager.recreateReactContextInBackgroundInner(ReactInstanceManager.java:440)
    at com.facebook.react.ReactInstanceManager.recreateReactContextInBackground(ReactInstanceManager.java:394)
    at expo.modules.updates.-$$Lambda$mn1Si_K9lL3awY-mNvAmj9EU9xE.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7397)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
    "react-native-screens": "~3.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-gesture-handler": "~1.10.2",
    "@react-navigation/bottom-tabs": "^5.11.7",
    "@react-navigation/drawer": "^5.12.3",
    "@react-navigation/material-top-tabs": "^5.3.15",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.14.2",
    "expo": "^41.0.0",

This is an Expo Managed app using the native stack throughout the app. I'm reticent to switch to the default stack due to the performance impact.

@Ideopunk please provide the reproduction of the crash so we can work on it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

beetlebum picture beetlebum  Â·  5Comments

harrisrobin picture harrisrobin  Â·  3Comments

joshua-augustinus picture joshua-augustinus  Â·  4Comments

jeveloper picture jeveloper  Â·  5Comments

Kinark picture Kinark  Â·  4Comments