Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing on Android since upgrading to 3.16.0 #1565

Closed
darrylyoung opened this issue Aug 19, 2022 · 20 comments · Fixed by #1566
Closed

Crashing on Android since upgrading to 3.16.0 #1565

darrylyoung opened this issue Aug 19, 2022 · 20 comments · Fixed by #1566
Assignees
Labels
Bug Something isn't working Platform: Android This issue is specific to Android

Comments

@darrylyoung
Copy link

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

@github-actions github-actions bot added the Platform: Android This issue is specific to Android label Aug 19, 2022
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added Missing repro This issue need minimum repro scenario Missing info The user didn't precise the problem enough labels Aug 19, 2022
@github-actions
Copy link

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

@kkafar
Copy link
Member

kkafar commented Aug 19, 2022

Hi @darrylyoung
are you using any specific setup regarding React Native (e.g. loading it on Fragment) or is it application with standard setup?

I'm ready to quickly rollback the changes introduced in https://github.com/software-mansion/react-native-screens/pull/1562/files & release 3.17.0 with the fix, but I would like to know the reasons why this happens first (as I tested it on fresh RN application and it worked with my setup).

@kkafar kkafar self-assigned this Aug 19, 2022
@darrylyoung
Copy link
Author

Hi, @kkafar. Thanks for the quick reply!

No, there's nothing special with my setup as far as a know. It was initially an Expo Managed project, but I ejected a while ago. I build the Android version using EAS Build. As you can see above, I'm using the latest Expo SDK, which uses React Native 0.69.4. I had no issues with that on iOS or Android. It's just since upgrading to 3.16.0 that I noticed the crash.

I know it's not the ideal solution, but I'm unfortunately not able to share any of the application code, so I can't add you to a repository, for example. If there's anything else I can do, though, please let me know.

Thanks for the support.

@SimpleCreations
Copy link

Just upgraded to the latest version and having the exact same issue.

"Failed to find fragment for React Root View"

@SimpleCreations
Copy link

It seems to happen every time I reload the app in dev mode (e.g. by pressing Ctrl+R) and goes away once I kill the app and relaunch it.

@kkafar
Copy link
Member

kkafar commented Aug 19, 2022

@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.

@freemanUA
Copy link

freemanUA commented Aug 19, 2022

got same issue, bare project RN 0.66.2
UPD: rolling back to 3.15 helps

@SimpleCreations
Copy link

@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
Copy link
Author

For context, in case this helps, I'm also using react-native-fast-image, but I didn't add it recently; I've been using it for over a year now and don't believe it's changed or been updated for quite some time.

@kkafar
Copy link
Member

kkafar commented Aug 19, 2022

@SimpleCreations, @darrylyoung

Thanks for your quick responses!

I managed to reproduce it with snippet provided by @SimpleCreations, will dive into it. For now I would love to hear from you whether this change solves the issue in your cases: #1566

To test it, you can simply put:

"react-native-screens": "software-mansion/react-native-screens#@kkafar/fix-fragemnt-manager-reproduction"

in your package.json, run yarn/npm install and rebuild the native code.

@kkafar kkafar added Bug Something isn't working and removed Missing info The user didn't precise the problem enough Missing repro This issue need minimum repro scenario labels Aug 19, 2022
@SimpleCreations
Copy link

@kkafar can confirm, the PR fixes the crash

@xmflsct
Copy link

xmflsct commented Aug 19, 2022

Confirm the PR fixed the crash

@alexco2
Copy link

alexco2 commented Aug 20, 2022

@SimpleCreations, @darrylyoung

Thanks for your quick responses!

I managed to reproduce it with snippet provided by @SimpleCreations, will dive into it. For now I would love to hear from you whether this change solves the issue in your cases: #1566

To test it, you can simply put:

"react-native-screens": "software-mansion/react-native-screens#@kkafar/fix-fragemnt-manager-reproduction"

in your package.json, run yarn/npm install and rebuild the native code.

fixes the bug for me as well

@kkafar
Copy link
Member

kkafar commented Aug 22, 2022

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

@jrhager84
Copy link

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?

@poonam5057
Copy link

Screen Shot 2022-08-22 at 12 43 29 PM
Hello I'm facing problem react-native-screen root failed to find fragment for react view. So please help me to resolve this error which varies on packages.
I have had to check the data storage of the application by clearing the cache so that the application works.

@darrylyoung
Copy link
Author

@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.

@poonam5057
Copy link

@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.

Thank you so much,
that works with downgrade.

@kkafar
Copy link
Member

kkafar commented Aug 25, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants