facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.49k stars 24.26k forks source link

React Native 0.61.1 and iOS 13.1.2 leads to lots of unneeded relaunches of our app #26696

Closed bobber205 closed 4 years ago

bobber205 commented 5 years ago

Last week we upgraded to the latest version of React. Around the same time my boss updated his phone to iOS 13.1.2 (got a new phone)

I have a iPhone 5S on my desk with iOS 12.x (whatever the latest in that branch is I updated it today)

I also run the app on my Android 10 phone.

After almost no time at all with the app not focused my boss's phone relaunches the app as if the phone just rebooted. Splash screen and everything. This doesn't happen on the very old iPhone 5. Not on Android either. Of course this relaunch can happen under certain circumstances that are reasonable. For instance my boss will open our app, open up IG and TW, then go back to our app and it relaunches.

We narrowed it down to our upgrade of .60.x to 0.61.1 last Thursday.

This is a very jarring UX issue. I'm not sure how to produce a reproducible use case since it depends on the latest version of iOS and I'm really busy trying to fix other bugs atm related to the new version of iOS. Has anyone else experienced this?

radko93 commented 4 years ago

Just so you are aware, this isn't only RN apps problem, Apple changed something in the latest iOS versions so it kills apps very quickly https://twitter.com/marcoarment/status/1189213173439696900

kdutcher commented 4 years ago

I’m not saying Apple hasn’t done something differently, but there is an issue in RN as well. By simply rolling back from 0.61.2 to 0.60.5 our app no longer crashes on ios 13 after 10 seconds in the background.

minhtc commented 4 years ago

This is a really crazy issue that took me a lot of time to investigate. I still haven't found the root cause, but I am pretty sure that it's related to "beginBackgroundTask" and "endBackgroundTask" inside RCTTiming, more detail here: https://forums.developer.apple.com/thread/85066

My temporary fix is replacing the file node_modules/react-native/React/Modules/RCTTiming.m with this one: https://gist.github.com/minhtc/78799bfb84c2d697034b9b53c4e01320 This fix is working on my production app.

bobber205 commented 4 years ago

@minhtc That's so awesome you got that far! Do you have to fork and publish your own version of React for that change?

minhtc commented 4 years ago

@minhtc That's so awesome you got that far! Do you have to fork and publish your own version of React for that change?

It's just a temporary fix so I don't create a fork, I'm using patch-package to update all the changes of file inside node_modules/

oleksandr-dziuban commented 4 years ago

@minhtc @bobber205 Guys, I have tested app on the latest iOS 13.2 My crash cannot be reproduced anymore. Also I don't receive crash reports from users on iOS 13.2 I think it was resolved on iOS system level

fonov commented 4 years ago

Terminated app in background is normal process for OS it not reproduce any crash reports.

bobber205 commented 4 years ago

@oleksandr-dziuban Just updated our iphone 11 to 13.2 Launched the app went a couple screen deep then started to take a couple photos + post on IG. Presss App Icon -- complete relaunch. Same actions taken on Android 10 (same build of app) stays on the same tab. Almost impossible to realistically get the app to do the same behavior on Android vs iOS it's simple. Even simple things like start editing in a text field, read a text via a push notification then swap back = reboot of app.

radko93 commented 4 years ago

@minhtc thanks for investigating, this might be the commit that is causing this issue https://github.com/facebook/react-native/commit/338298417f8077dee177057c57b38671b4ec8c75#diff-29f34a4d1c9b73a44351941dae6056c8

bobber205 commented 4 years ago

Anyway known way (hard or easy) to disable that functionality for consumers who don't need it? 🙏

radko93 commented 4 years ago

I submitted a PR to fix that for 0.61.x, You can upvote it there https://github.com/facebook/react-native/pull/27065 . If it gets merged then it will be available in 0.61.4.

zhongwuzw commented 4 years ago

Hi, anyone can try new a project(not include RN), just begin a background task to see wether it terminated by system? code like https://github.com/facebook/react-native/commit/338298417f8077dee177057c57b38671b4ec8c75#diff-29f34a4d1c9b73a44351941dae6056c8R150-R157.

zhongwuzw commented 4 years ago

I reviewed the timer module again, I may suspect there have thread-safe issue, @bobber205 @oleksandr-dziuban can you guys can help to dig in? Replace 3 methods in RCTTiming.m like https://github.com/facebook/react-native/pull/25164/files#diff-29f34a4d1c9b73a44351941dae6056c8R174-R202, and try wether it crashed on iOS 13.1. Thanks.

bobber205 commented 4 years ago

I can try next week

On Fri, Nov 1, 2019, 8:46 PM Wu Zhong notifications@github.com wrote:

I reviewed the timer module again, I may suspect there have thread-safe issue, @bobber205 https://github.com/bobber205 @oleksandr-dziuban https://github.com/oleksandr-dziuban can you guys can help to dig in? Replace 3 methods in RCTTiming.m like https://github.com/facebook/react-native/pull/25164/files#diff-29f34a4d1c9b73a44351941dae6056c8R174-R202, and try wether it crashed on iOS 13.1. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/26696?email_source=notifications&email_token=ABMSBU74VOQGEJALVOSHKYDQRTZZLA5CNFSM4I44TOJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC4S52A#issuecomment-549007080, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMSBU3CEMWRTSY3TS6BAOTQRTZZLANCNFSM4I44TOJQ .

radko93 commented 4 years ago

You can now try 0.61.4 as it includes a fix.

radko93 commented 4 years ago

This is now fixed on 61 branch and on master.

sarthak-synclovis commented 4 years ago

Still having same issue. Works fine on simulators as well devices upto iPhone 8. For devices of X series, crash is happening still after 2-3 minutes

octodhruv commented 4 years ago

any other ideas what could cause this? Upgrading to .61.5 didn't fix this for me :/

vforvasile commented 4 years ago

@sarthak216-blr , @octodhruv are you guys using Websockets?

octodhruv commented 4 years ago

@vforvasile Nope - no websockets.

unalkiran commented 4 years ago

1- app closed (not in background) 2- received a notification 3- click app icon or click notification for launch 4- app crashes at didFinishLaunchingWithOptions. cause RCTCxxBridge _handleError. 5- kill app and launch again, app is opening without error !

can anyone help?

terijyu commented 4 years ago

This is causing serious issues for us as well @radko93

hugw commented 4 years ago

@vforvasile @radko93 Hi. I'm curious why you asked if we are using Websockets. Could you provide more details on how would that cause the problem?

skyfx64 commented 4 years ago

I have exactly the same issue and currently fix it with RN 0.61.5, but when using 0.61.4 sometimes unstable.