-
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
Restarting app via instanceManager.recreateReactContextInBackground leads to crash #2331
Comments
+1 |
I want to clarify that the main concern here is
Could you please guys confirm that this is valid scenario for RNN screen registration? If it is could you please give us any idea how this issue could be resolved? |
Hi guys could you please take a look on it? |
If I understood correctly, it seems that, this issue prevents every Android user that implements RNN from code-pushifying their app if they're using AsyncStorage before they register the screens. |
Any updates on this? |
I have a similar issue, that the navigation is broken after a codepush restart. Just if I restart the app again afterwards (in my case I first have a singleScreenApp for onboarding and then a tabBasedApp, that's how I encountered this), it seems to work. So I assume that is has something to do with the order in which some code is executed in this case. |
@MrLoh also have this problem. During development, a code reload just works fine and navigation is working. With Code-Push mandatory updates, the app reloads and then navigation is broken. @ruslan-bikkinin thanks for this plugin, with it I could verify that it is broken after the reload. And of course when I am connected to the debugger and use the @MrLoh could you find out anything that helps? We are also using AsyncStorage to persist our redux state. |
Hm, I found out that when I do the reload, switch to a So maybe there is some global stuff that needs to be re-initialized or something? |
As a workaround, I am currently always starting an empty (just a single white screen) singleScreenApp before I start the main app. This is a really ugly workaround, but at least it works. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
I moved away from react-native-navigation because of this issue, it's probably not been resolved yet. |
Can confirm its not been resolved, presently trying to figure out a workaround... based on my cursory exploration, it appears the crux of the issue is: the However, because the context hasn't actually been fully recreated, the JS bundle has not been parsed & run, and To be quite honest I'm not fully sure this is correct, and I don't yet understand why this isn't an issue when RNN is not integrated -- this is what I'm attempting to determine now. My guess at a fix would be removing the dying If anyone has any ideas for how we might be able to detect the call to |
Quick follow up to my (painfully long) previous comment, if I hack apart the restart functionality and use Now how to do this without the hack is the billion dollar movie... |
FYI, I put together a minimal repro here. |
fwiw the PR I submitted that's linked above seems to fix this bug for me... I'm a bit worried about potential race condition but so far I have yet to see one arise. |
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. |
Ok, do I assume correctly that code push can not be used with react native navigation v.1 on Android? Does it make sense to upgrade to v2 or the issue would still persist there and better to move to react-navigation (what I would like to avoid)? |
@terreb We've been using codepush and RNN v1 for months now without issues. |
@SudoPlz are you using codepush configured with |
Nope, I'm using |
@SudoPlz, I tried both before and after and in both cases I have a crash if not using ON_NEXT_RESTART install mode. Would you mind to share a minimum working repo on Android with RNN 1 and code push? |
@terreb Unfortunately I'm too busy to do that at the moment, but we don't do anything extra-ordinary, we're just registering the screens first, and THEN use AsyncStorage. |
@terreb are you red screen/crashing on android when restarting? try implementing what I did in this PR and see if it works for you then. (I'm really not sure how its working for sudoplz, there's a bug on android where it attempts to reattach views to a dead JS context which crashes when built for prod and red screens in dev mode). |
@ericketts, no I don't get a red screen, the app just closes when crashing. I'm testing on a Genymotion emulator, it might behave differently on a real device but I don't have any around. Yes I saw your PR and wanted to thank you for your efforts. However I hesitated with trying it because most likely it won't be integrated in an official version. I decided to migrate to v2 and see if it works there. Thank you again. |
@terreb yeah for sure, we just migrated to v2 and it so far doesn't seem to have the numerous issues experienced on android in v1... also as far as crash vs red screen, what is a red screen when building for dev will be a runtime crash when built for prod, so you're really getting both most likely... the red screen helps explain the issue so it can be useful to build in dev mode for that reason! |
@ericketts, ok I got you and I know what the red screen is:) The thing is it works in dev mode and not crashing. In this case, if I understood correctly, code push uses RN bundler to load the package. I get the crash only in production, so no red screens there:) |
Migrated to RNN v2, the same issue, this is very frustrating:( |
Its curious because it appears as though there is code in the V2 rearch specifically to handle the issue that was causing this crash bug, but it apparently isn't working as like @terreb I still see this issue arise in V2. unfortunate that this issue was closed, it is not at all solved. |
@ericketts can your PR be adapted to V2? I have this issue on V2 as well... |
@ujwal-setlur I had a quick look at the internals of android V2, and it looks sufficiently different that I can't simply graft the previous fix onto the new code... however the crash is affecting the app we're developing presently, so I would not be surprised if there comes a time where I will need to figure out a fix for V2, at which point I would definitely (at least attempt to) get it merged back in to the main codebase. |
Destroy navigation activity layouts on catalyst instance destroy addresses #2331 & microsoft/react-native-code-push#1144
@ericketts Our app crashes selectively on code push (most devices crash, others not). We use this Is there any solution to this now? We have |
@afilp it really depends on why exactly things are fucking up, I'd have to investigate your app and stack traces and all that jazz to answer with any certainty. I can tell you I had to whack-a-mole about 2 or 3 different reasons (sounds worse than it really was since that was between v2 and v3) now if you're hiring... 😄 |
@bitpit are you the same person as @ericketts ? |
Hello, I still have the problem. Why is this issue closed? |
Can we re-open this issue ? I don't see any awnsers ! |
Issue Description
We are working on react-native-code-push module for CodePush and facing troubles investigating this.
Briefly, we are providing API method for "soft" app restart (e.g. without killing application) using RN context restarting mechanism based on
instanceManager.recreateReactContextInBackground();
method ofReactInstanceManager
class and for some RNN scenarios this approach leads to the app crashes.I am asking for assistance from you guys to help us to figure out what could be the source of problem here because restarting breaks only for
react-native-navigation
apps and works like a charm with usual RN app.Steps to Reproduce / Code Snippets / Screenshots
App.js
:npm i
. It uses react-native-restart package that contains pure restart code API extracted fromreact-native-code-push
../gradlew assembleDebug
fromandroid
directoryExpected Behavior:
No crash, only one registered application is running.
Actual Behavior:
For some reason RN tries to run old application too instead of running just the new one.
Environment
The text was updated successfully, but these errors were encountered: