-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: attempt to fix assertion errors in ReactInstanceManager #4160
Conversation
I don't like that it only masks the problem. Can you give more details on what device it happens and what version of the app ? Are we sure does not come from someone using the SDK in wrong way ? |
facebook/react-native#24455 It's not clear on what devices it happens, but we are not alone in this one. This is an attempt to survive a crash, so avoinding the issue is 100% intentional. |
One thing I've noticed is that we're calling |
Yes, that in order to support PiP properly. When in PiP the Activity gets onPause called, but we don't want to let React know, since it would emit the state that we are in the background, but we are not. |
Okay, makes sense. It's good to place things like that in comments in the code |
@saghul here's the scenario to repro the issue. I am able to repro on Samsung with Android 8.0.0
|
I can not repro on One Plus 5 |
#4183 should fix the issue I am able to repro. Do we still want any parts of this PR ? |
@paweldomas Thanks for #4183 ! I think we have 2 choices here:
FTR, based on our Crashlytics reports, this issue is our top-most crash and the one that affects more users. So, I'd say let's go with 1) and keep this open and monitor the situation, if we see crashes still coming, we land this PR and release a .1 with it. WDYT? |
Okay lets hold with this one then. I suppose that we should stop seeing this crash after the PiP fix, but also knowing what the issue is I think that not calling the pause would avoid the crash and maybe not cause any side issues. Because at the time when it happens react is already hooked up to new activity. |
But then it's likely that this kind of situation will be causing leaks, because we never assume to have more than one instance of activity at a time. |
I wouldn't worry too much. Looks like we are not alone and that somehow it's possible for that to happen: https://stackoverflow.com/questions/46985698/singleinstance-activity-launched-twice-intermittently-on-android-8-oreo but the OS will kill the other Activity. Our delegate will only keep track of the active one, so we should be good. All of that ⬆️ applies if we do the hack this PR is, but let's wait until the next release. |
Approved, but please let's wait to clear up Pawel"s concerns around leaks and pip |
This PR has to be approved. ReactInstanceManager's lifecycle handling is not right. |
I’ll check if we have seen this assertion trip after our other changes, thanks for the reminder. |
Thanks for the answer @saghul . |
This is the main one: https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512 Why this happens is a mystery wrapped in an enigma.
f4a7cad
to
88221d8
Compare
@paweldomas I checked the crashlytics reports and I still see crashes because of this. Can you review again? For context: #4160 (comment) |
I think it would do the B's pause in the case you describe above, because B would still be the current activity. |
@jackyoo That scenario should not be possible, but it somehow happens. See https://stackoverflow.com/questions/46985698/singleinstance-activity-launched-twice-intermittently-on-android-8-oreo |
This is the main one:
https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512
Why this happens is a mystery wrapped in an enigma.