react-native-screens: Crashing on Android since upgrading to 3.16.0

Description

Hi, everyone!

Since upgrading to 3.16.0, my app is crashing on Android when launched. Upgrading react-native-screens was the only thing I’ve done since having a working build, so it seems like the issue is related to the upgrade. Apologies if I’ve missed something, but I didn’t see any specific actions I needed to take when upgrading in the release notes.

This is what I see when launching the app in a Pixel 5 emulator in Android Studio.

Screenshot_20220819_113957

Here's the raw text from the exception captured in Sentry
java.lang.IllegalStateException: Failed to find fragment for React Root View
    at com.swmansion.rnscreens.ScreenContainer.findFragmentManagerForReactRootView(ScreenContainer.kt:168)
    at com.swmansion.rnscreens.ScreenContainer.setupFragmentManager(ScreenContainer.kt:198)
    at com.swmansion.rnscreens.ScreenContainer.onAttachedToWindow(ScreenContainer.kt:228)
    at android.view.View.dispatchAttachedToWindow(View.java:20753)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
    at android.view.ViewGroup.addViewInner(ViewGroup.java:5290)
    at android.view.ViewGroup.addView(ViewGroup.java:5076)
    at com.facebook.react.views.view.ReactViewGroup.addView(ReactViewGroup.java:466)
    at android.view.ViewGroup.addView(ViewGroup.java:5016)
    at com.facebook.react.uimanager.ViewGroupManager.addView(ViewGroupManager.java:37)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:533)
    at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.manageChildren(ReanimatedNativeHierarchyManager.java:306)
    at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:217)
    at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
    at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
    at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
    at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
    at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
    at android.view.Choreographer.doCallbacks(Choreographer.java:845)
    at android.view.Choreographer.doFrame(Choreographer.java:775)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7842)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

If I can provide any more information that would help, please let me know. Thanks!

Steps to reproduce

  • Upgrade to 3.16.0
  • Build the app
  • Set up a fresh emulator
  • Run the app and see the crash upon load

Snack or a link to a repository

Screens version

3.16.0

React Native version

0.69.4

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Real device

Device model

Google Pixel 3

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 20 (5 by maintainers)

Most upvoted comments

Ok, thank you for your replies. You can expect 3.17.0 coming with the fix within days.

Ok, so I’ve just released 3.17.0, hope it works fine this time for you.

@poonam5057 That screenshot shows the same error I had in my screenshot in the original comment here. As mentioned by one of the maintainers, the issue has been fixed and will be fixed in 3.17.0, which is to be expected in the next few days. You can try downgrading to 3.15 if you need a solution right now.

@kkafar I was able to narrow it down 🎉

The crash starts happening after adding react-native-fast-image and is triggered when reloading the app through the dev menu.

import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import React from 'react';
import FastImage from 'react-native-fast-image';

const Stack = createNativeStackNavigator();

const Screen = () => (
  <FastImage
    style={{width: 200, height: 300}}
    source={{uri: 'https://picsum.photos/200/300'}}
  />
);

const App = () => (
  <NavigationContainer>
    <Stack.Navigator>
      <Stack.Screen name="Screen" component={Screen} />
    </Stack.Navigator>
  </NavigationContainer>
);

export default App;

@darrylyoung, @SimpleCreations Would you mind posting a reproduction for me, since I’m trying as heck to reproduce this now & cant

I created fresh RN 0.69.4, added react-native-screens@3.16.0, added example using screens & native stack and everything works as expected even when refreshing in dev-mode. Not mentioning that it works as expected in our Test/Example applications.

Edit: Just now created fresh Expo (SDK 46) application, installed screens, ejected -> works as expected.

Reproduction is required.

Rolling back to 3.15 fixed the error, but now my React navigation native stack is blank on Android. Works perfectly find on iOS. I haven’t changed any of the code for the Stacks while working on this screens fix.

Is anybody else getting that? Is it a symptom of these issues, or did something get messed up?