-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[v2] Tried to create view after it has already been destroyed #3767
Comments
same |
somebody pls remember me to show you how to reproduce, i know how, very busy right now, might forget |
See the same crash in Android only. In my case, it happens when a child screen is popping (the pop animation is running) when the setRoot() method is called. If I set the pop animation's duration to 0, it works without any problem. So I think the pop animation is the culprit here. Hope this information can help you resolve the issue. |
Unfortunately I can't fix this one without a reproduction, @nezaidu ? |
getting the same thing but no consistent way of reproducing this. |
@starzle Have you tried |
@guyca In our case, the setRoot is called when componentDidAppear is triggered. And apparently, componentDidAppear is triggered before the pop animation ends. So we don't have a place where we can await the pop. But if we simply add a delay to the setRoot call, then as long as the delay is long enough to make sure pop animation is already finish (onAnimationEnd called if I am correct) when setRoot is called, then the crash goes away. In short, pop's onAnimationEnd needs to be called before setRoot. Hope this info can help you. |
after add code push relative, java.lang.RuntimeException: Tried to create view after it has already been destroyed |
i have same issue |
|
this also occurs when you have a root view, navigate to a new view with pushTo from a modal and then try to setStackRoot within the main application. |
To add to my colleague @reganperkins above, our error is the same but the stacktrace does not seem entirely identical.
We managed to find a workaround that may (or may not!) clarify the situation. As she was saying, the control flow in our scenario is this:
The workaround: Close the modal before pushing the new view, deferring the push using |
I can confirm this happening as well. In my case I'm calling a Heres the stack from the crash, only affects android devices.
|
Any update on this @guyca ? |
Wrapping the |
@makirby can you please share a snippet for the solution? |
Basically where we were making a
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
probably not stale |
Can confirm I've just started facing this, thanks for the catch @zabojad 👍. This seems to be Android only. Edit: This was actually my own fault (although the hard crash without indication wasn't ideal). This is also replicable on android if you try to push to a screen twice from the same component id. iOS side silently deals with it. |
Here is my code for reproduce this issue & also found tricks to solve the issue :
I placed 20 in for() to make sure that error happens, because this issue doesn't happen always. But we have two choice to get rid out of that: 1. Making app layout structure with just 1 Navigation.setRoot() and then use .push() .pop() .popToRoot() to manage navigation, it should work but still is risky because i faced 2. Simply comment (or delete :) bellow line in ViewController.java:
This worked for me without any problem, that is a quick TEMPORARY solution, not PERMANENTLY. (ViewController.java is here : /node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/) |
If I try use method 2. mentioned by @bahmannejati , I have segfault instead that exception |
Sorry @varungupta85 for delay. In my case, I have two navigations one Stack and one with BotoomTabs. And to manage this navigation I have a Component with Redux. What happened was that this component was updated more than once by Redux and with that, the setRoot was also called and the app crashed. |
My app consists of BottomTabs containing stacks of screens. Whenever the BottomTab is changed, I call Navigation.popToRoot() for the tab that the user is leaving. I can reproduce the crash by pushing a screen to the stack of a tab (with waitForRender in push animation) and then quickly changing to another tab and back. It sounds like #4842 addressed that issue, but I am running v2.16.0 and still get the error. |
@fliPmitKlammern Could you please push a branch with a reproduction in the playground app? |
Got this today, going with commenting it out for now as suggested earlier |
This issue is still in Android. I got the same error but different logs tho:
|
The issue still reproduces on Android: after app start press back button and start app again -- crash occurs with same stack. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
The issue has been closed for inactivity. |
When popToRoot or popTo where called while a screen was pushed, at the end of the push animation RNN tried to destroy an already destroyed ViewController. Related to wix#3767
This PR includes a series of fixes that attempt to alleviate crashing when restarting the bundle on Android. - Use BB fork of react-native-restart package which contains a fix to the Android code - Wrap Navigation.setRoot() in fsapp inside runAfterInteractions which appears to help alleviate Navigation being clobbered on startup (inspired by wix/react-native-navigation#3767 (comment)) - Refactor tab logic in fsapp so that tabs are generated before setting them in the Navigator - Update tab schema to follow recommended format (wix/react-native-navigation#5096 (comment)) - Removed non-printable character from PirateShip initialization config - Removed setStackRoot() calls in PirateShip that were being used when authentication failed on app startup. These appeared to be clobbering Navigation when it was trying to initialize the app.
This bug is still here (version 6.7.5) |
Upgraded to fix the crashes but I still see the crashes in firebase. |
We still see the crash with version 7.8.4 |
Still seeing crashes occur in Crashlytics on app using |
Any updates on this? |
This issue still exists in 7.27.1 |
This issue still exists in 7.27.1、7.28.1、7.29.0 |
This PR includes a series of fixes that attempt to alleviate crashing when restarting the bundle on Android. - Use BB fork of react-native-restart package which contains a fix to the Android code - Wrap Navigation.setRoot() in fsapp inside runAfterInteractions which appears to help alleviate Navigation being clobbered on startup (inspired by wix/react-native-navigation#3767 (comment)) - Refactor tab logic in fsapp so that tabs are generated before setting them in the Navigator - Update tab schema to follow recommended format (wix/react-native-navigation#5096 (comment)) - Removed non-printable character from PirateShip initialization config - Removed setStackRoot() calls in PirateShip that were being used when authentication failed on app startup. These appeared to be clobbering Navigation when it was trying to initialize the app. brandingbrand-source-id: 42d0e5126eb8c5594ca4bf6c17b95106f487e4fa
My app users are complaining about random crashes on Android. I have Crashlytics installed and I verified by using user and time filters that this crashes are caused by the following error:
I can't reproduce the problem in the Android simulator and it seems Android exclusive, as it appears. Can anyone help me what might be happening?
Thanks in advance.
Environment
The text was updated successfully, but these errors were encountered: