-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
[Android] Crash: no view found for id 0x1f1 (unknown) for fragment ScreenFragment #54
Comments
This happens to me everytime i use react-navigation with some rehydrated state (redux-persist) and try to navigate into another stack in a switch navigator as soon as the app starts (ex: user already logged). I will try to make up some repro to make this problem more clear... But i get the same error in android studio and just by removing |
This happens to me too whenever the app is updated with a new version from the play store (only if using screens). It crashes, then the next time app starts all is good. |
I'm having the same issue. I couldn't be sure it was an issue with this lib, but I tried removing it and the crash stopped. Does anyone have an idea where to start looking to solve this? |
It seems that the newest version I updated it here and it worked for me. |
Indeed, the new version 22, is working for me too. Caveat: simply running EDIT: the crashes started happening again after installing |
@fjcaetano That's interesting, I have been using that splash screen library for quite a white and I was wondering if that might be the cause :P Any idea why moving to componentDidMount in that case works? |
Experiencing the same problem on alpha-22, but without using However all the crashes happened after navigating to our The problem does not appear on iOS nor when disabling react-native-screens on Android. I haven't tried moving Here is the full trace:
|
I believe moving to Our app is now working correctly. I've checked on iOS and |
Unfortunately, after moving
Any other possible workaround? Thanks! |
Not sure if this is related, but I have hunch it might be. We are experiencing this issue when moving between screens inside a When I change |
We also use |
@kmagiera fixed on 1.0.0-alpha.22 |
Hi, we were still experiencing this with 1.0.0-alpha.22 Specifically when using a switch navigator and navigating between scenes in the switch navigator. |
Same scenario here |
I've been doing a bit of digging on this issue. Still haven't found a solution, but I did make some observations. @kmagiera Could you take a look at some of the observations below to see if you have any ideas?
I'm wiped for today, but I'm going to continue looking into this tomorrow, so if anyone has any more data or observations to share I'd appreciate it. |
This issue is happening because this library is not using Fragments correctly. The issue happens when a However, it appears the expectation in android is that these sort of operations should be handled through the If the |
It would be great if we could get this fixed, because as far as I can tell you can't use the react navigation switch navigator without it. This makes it hard to implement our auth flow. We've been forced to disable |
Here's a minimal reproduction: import React, { PureComponent } from 'react'
import { View } from 'react-native'
import { useScreens } from 'react-native-screens'
import {
createSwitchNavigator, createStackNavigator, createAppContainer
} from 'react-navigation'
useScreens()
function SomeLoginScreen() {
return <View style={{ backgroundColor: 'blue', flex: 1 }} />
}
function SomeAppScreen() {
return <View style={{ backgroundColor: 'red', flex: 1 }} />
}
const LoginStack = createStackNavigator({
Form: SomeLoginScreen
})
const AppStack = createStackNavigator({
Home: SomeAppScreen
})
const Navigator = createSwitchNavigator({
Login: LoginStack,
App: AppStack
})
class App extends PureComponent {
static router = Navigator.router
componentDidMount() {
// Crash:
this.props.navigation.navigate({ routeName: "App" })
// Does not crash
// setTimeout(() => this.props.navigation.navigate({ routeName: "App" }), 0)
}
render() {
return <Navigator {...this.props} />
}
}
export default createAppContainer(App) I suspect that there may be multiple ways of triggering this crash, but the code above seems to cover the Switch navigator case specifically. |
I have a very ugly workaround that uses reflection, but it's enough to get running. You can see it here. Note: That branch should not be used as is without careful consideration. There's a few changes in there specific to the environment we're using, so please only consider it as reference. Note 2: If using this hack with proguard, make sure you don't mangle |
Seems like RNS doesn't work well along with inlineRequires=true in metro config. After enabling it app crashes every time it starts with 'No view found for fragment' error. |
I tried to swap in the SwitchNavigator from react-navigation-animated-switch to see if that might be a viable workaround for this issue. Unfortunately, it fails in the same way and it also exhibits a number of different (but probably related) crashes: https://github.com/react-navigation/animated-switch/issues/6 |
same here:
|
same android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1454) |
@TikiTDO your reflection hack worked for me :) do you know what possible downsides there could be? |
unfortunately i found a downside to @TikiTDO's hack repro: after every return from bg, react will mount the app container anew, but any JS state you may have accumulated will still exist. In our project, this caused all kinds of non-idempotent initialization to break |
@kmagiera are there any estimations on fixing this? |
Thanks for sharing your workaround @TikiTDO. |
@ariya I don't understand the question. It's significant because it's the variable that's at the root cause of the bug. I have a post higher up that explains the code flow that leads to the issue. However, I'm not an android developer, so I can't tell you what this variable is used for or what it should be set to in any given situation. I'm just good enough with a debugger to trace a null pointer exception to it's cause. As @mvayngrib pointed out, there are fairly big problems with the workaround, so really this is just an issue that's looking for a bit of love from someone that actually knows this environment |
We are facing this problem after upgrading "react-native": "0.61.4" This also occurs with |
Facing this issue as well. App crash after launch. Package versions
Android LogCat Output:
edit: not using |
Facing this issue as well. App crash after launch. "react-native": "0.59.9", |
Hi, I also experience this error after I add react-native-community/netinfo, when I turn off the connection the app crash and shown the same error.
is there any solution yet? |
Facing this issue too. Disable react native screens and all works perfect! |
Thanks everyone for contributing in this discussion. I'd love to help resolve this issue. However, before I start it would be helpful if someone form the folks experiencing the crash could come up with a repro case. I went through the comments and maybe I missed the repro being posed, the closes was this comment #54 (comment) by @thomasw but it only shows some code with no repro steps and rendering the app from the comment does not seem to cause the crash. If you are willing to help get this ticket resolve please provide a code with repro steps (instructions how to run the sample and details on your setup: what device, which RN version etc) |
Hi @kmagiera, I've managed to create repro https://github.com/dominiczaq/react-native-screens-no-view-found-issue The issue is occurring when component renders It seems that there are no issues when Stacks are changing rapidly, only when the Stacks are unmounted while navigating. |
This change fixes issue reported in #54. The issue was caused by the fragment transaction that run past the moment when container view is detached. This could happen when container is quickly added and removed as fragment transactions sometimes may take long time to execute. Unfortunately enqueued fragment transactions cannot be cancelled, so to make sure that transaction isn't run past container unmount we call executePendingTransactions right before the screen is detached.
This change fixes issue reported in #54. The issue was caused by the fragment transaction that run past the moment when container view is detached. This could happen when container is quickly added and removed as fragment transactions sometimes may take long time to execute. Unfortunately enqueued fragment transactions cannot be cancelled, so to make sure that transaction isn't run past container unmount we call executePendingTransactions right before the screen is detached.
@dominiczaq do you know if the merged changes fix the bug? |
Yes, the fix works. I believe this issue could be closed. |
Hi @WoLewicki I'm still seeing this crash on the app making use of |
Hi @henrymoulton The issue was resolved by adding the following code in App.js: |
Thanks man, helped a lot |
Thank you! |
Today, I attempted to update to the latest
react-navigation
, and I figured I would try to usereact-native-screens
to improve performance. Unfortunately, it crashes on Android immediately upon opening. I have followed all of the instalation instructions, and I can confirm that my code works fine if I a) do not calluseScreens()
and b) extend fromReactActivity
instead in the code below.The exception only shows up in adb logcat:
Here is my MainActivity.java.
Any thoughts on fixing this? My one thought might be that there is a conflict with something else. Not sure, though.
The text was updated successfully, but these errors were encountered: