Skip to content
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

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

Closed
bobber205 opened this issue Oct 2, 2019 · 74 comments
Labels
Bug Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@bobber205
Copy link

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?

@bobber205 bobber205 added the Bug label Oct 2, 2019
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Oct 2, 2019
@react-native-bot
Copy link
Collaborator

Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?

👉 Click here if you want to take another look at the Bug Report issue template.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: Needs More Information labels Oct 2, 2019
@radko93
Copy link
Contributor

radko93 commented Oct 3, 2019

Are you sure your app is not crashing in the background? Do you have any crash reporting service enabled?

@bobber205
Copy link
Author

bobber205 commented Oct 3, 2019

@radko93 Pretty sure it's not crashing. I've narrowed it down to a commit that was responsible for the 0.61 upgrade -- before that commit doesn't matter how long you put the app in the background (say 10 minutes) it's still active when you come back.

We've noticed as little as 1 minute timed of launching the app going over to Instagram and doing literally nothing for a minute then back to our app, relaunch.

We have no background processes for this app. And while we don't have a ton of devices to test on at the moment we have only noticed it on the latest iOS.

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 7, 2019

@bobber205 @radko93 Have almost same issue
I have described it in #26746

Just app is really crashing on iOS 13.1.2 when device is sleeping or app just staying in background
Stracktrace crash report is available in my issue

@bobber205
Copy link
Author

@oleksandr-dziuban
image

@radko93
Copy link
Contributor

radko93 commented Oct 8, 2019

Are you using Websockets @bobber205 @oleksandr-dziuban ?

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

Are you using Websockets @bobber205 @oleksandr-dziuban ?

No, I don't use Websockets.

For data transport I use GraphQL based on Apollo Client without Websockets.
For Native features I use these libraries only:

    "@react-native-community/async-storage": "1.6.2",
    "@react-native-community/netinfo": "4.2.2",
    "react-native": "0.61.2",
    "react-native-dynamic-fonts": "0.3.1",
    "react-native-image-crop-picker": "0.25.2",
    "react-native-keyboard-aware-scroll-view": "0.9.1",
    "react-native-popup-menu": "0.15.6",
    "react-native-render-html": "4.1.2",
    "react-native-restart": "0.0.13",
    "react-native-router-flux": "4.0.6",
    "react-native-share": "2.0.0",
    "react-native-sqlite-storage": "4.1.0",
    "react-native-svg": "9.9.5",
    "react-native-version-number": "0.3.6",
    "react-native-view-shot": "3.0.2",
    "react-native-webview": "7.2.7",
    "react-native-woodpicker": "0.0.17",
    "rn-fetch-blob": "0.11.2",

There are no background processes in the app.

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@radko93 Just interesting, I have found how to reproduce that even on iOS 13.0 Simulator with Xcode 11.0

  1. Just open an application
  2. Work with it some time
  3. After this click on hardware "ON/OFF" button on Simulator
  4. Wait 1-2 minutes to emulate sleep mode
  5. Unlock device again
  6. Application will be crashed

Veeery tricky issue....

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@radko93 Yes, very easy to reproduce even on newest iOS 13.1 Simulator (Xcode 11.1)

Also reproduced on iOS 13.1 Simulator iPhone 11 (Xcode 11.1):

  1. Open an application
  2. Emulate device sleep mode: click on hardware "ON/OFF" button on Simulator
  3. Screen should be black now
  4. Wait 1-2 minutes in this sleep mode
  5. Unlock device again
  6. Application will be crashed without any error

For best crash detection I use react-native-debugger with Memory Tab: when application will be crashed - we will see that in Select Javascript Area VM instance field

@radko93
Copy link
Contributor

radko93 commented Oct 8, 2019

@oleksandr-dziuban it's complicated because I cannot reproduce it for now with my app on RN 0.61.2.

@oleksandr-dziuban
Copy link

Did you wait 1-2 minutes in sleep mode on simulator?

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

Maybe this is native libraries specific issue? Some library is crashing in sleep mode, maybe react-native-webview, maybe netinfo.... Tricky case....

@radko93
Copy link
Contributor

radko93 commented Oct 8, 2019

@oleksandr-dziuban I wait 10 or more minutes on iPhone 6s with latest iOS (Release build). Might be netinfo, try to comment it out. Try to comment out different things and see if it helps.

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@radko93

I'm using Apollo Client for GraphQL data transport, it can use Websockets under the hood for GraphQL subscriptions

Maybe this causing crash

Additionally I will comment all Native packages one by one to check

@oleksandr-dziuban
Copy link

Disabled NetInfo, WebView - nothing changed

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@radko93 I have reproduced this even on fresh react-native app without any additional code!

Steps:

  1. Use iOS 13.0 or 13.1 Simulator, Xcode 11.0 or 11.1, react-native@0.61.2
  2. Generate fresh app: react-native init TestApp
  3. Run iOS app in Simulator: react-native run-ios --simulator="iPhone 11"
  4. Wait until application will be assembled and home screen activated
  5. Click on Hardware Power Button on the right side in Simulator, device will activate sleep mode
  6. Wait ~ 1 min and Unlock Simulator screen
  7. Application will be crashed

@SYoder1
Copy link

SYoder1 commented Oct 8, 2019

This is the same issue that I am seeing, but I am on react-native: 0.59.8

@bobber205
Copy link
Author

Are you using Websockets @bobber205 @oleksandr-dziuban ?

i don't use Websockets either.

@bobber205
Copy link
Author

@SYoder1 Good to know! I think that means this is a React Native + newest version of iOS issue not specific to a version of react (seems that way anyway)

@SYoder1
Copy link

SYoder1 commented Oct 8, 2019

@bobber205 I am also not using Websockets

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@bobber205 Yes, I think in iOS 13 we have new mechanism for sleep/awake in apps and something went wrong now with react-native apps.

@ozgursoy
Copy link

ozgursoy commented Oct 8, 2019

@oleksandr-dziuban I tried but my app did not crash.
But i added some capabilities on Xcode

Background Modes is enabled
Audio, Airplay ...
Background Fetch
Remote notifications

and these are selected

@oleksandr-dziuban
Copy link

I will try to do the same

@oleksandr-dziuban
Copy link

oleksandr-dziuban commented Oct 8, 2019

@Farad4y @bobber205 I have added this capabilities.
I see a bit different behaviour now:
Application is not crashing, it is in Active App List, but when I select it again it starting from scratch.
Looks like app was totally refreshed, something like when RAM is not enough to keep app active.

@bobber205
Copy link
Author

@oleksandr-dziuban That's exactly what we're seeing.

@radko93
Copy link
Contributor

radko93 commented Oct 30, 2019

@minhtc thanks for investigating, this might be the commit that is causing this issue 3382984#diff-29f34a4d1c9b73a44351941dae6056c8

@bobber205
Copy link
Author

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

@radko93
Copy link
Contributor

radko93 commented Oct 30, 2019

I submitted a PR to fix that for 0.61.x, You can upvote it there #27065 . If it gets merged then it will be available in 0.61.4.

radko93 referenced this issue Oct 30, 2019
Summary:
Related #23674, in that PR, we imported background timer support, but it's not sufficient, I think the reason that works is because it enable the `Background Modes` and do some background tasks, for the users who don't enable it, timer would pause immediately before goes into background.

To fix it, we can mark a background task when goes into background, it can keep app active for minutes, try best to support timing when in background.

cc. cpojer .

## Changelog

[iOS] [Fixed] - Timing: Fixes timer when app get into background
Pull Request resolved: #24649

Differential Revision: D15554451

Pulled By: cpojer

fbshipit-source-id: a33f7afe6b63d1a4fefcb7098459aee0c09145da
radko93 added a commit that referenced this issue Oct 31, 2019
radko93 added a commit that referenced this issue Oct 31, 2019
radko93 added a commit that referenced this issue Oct 31, 2019
This PR reverts commit 3382984 that is causing #26696 #26995.
@zhongwuzw
Copy link
Contributor

Hi, anyone can try new a project(not include RN), just begin a background task to see wether it terminated by system? code like 3382984#diff-29f34a4d1c9b73a44351941dae6056c8R150-R157.

@zhongwuzw
Copy link
Contributor

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
Copy link
Author

bobber205 commented Nov 2, 2019 via email

@radko93
Copy link
Contributor

radko93 commented Nov 4, 2019

You can now try 0.61.4 as it includes a fix.

facebook-github-bot pushed a commit that referenced this issue Nov 5, 2019
…27073)

Summary:
This PR reverts commit 3382984 that is causing #26696 #26995.
> app would be closed immediately after going to background on iOS 13.1/13.2 and was investigated by minhtc #26696 (comment). The commit that is being reverted is apparently causing the app to be closed immediately. This has to be reverted in master separately as the file differs there.

Similar PR for 0.61. branch #27065

## Changelog

[iOS] [Fixed] - Fix apps crashing on iOS 13.x when running timer in the background
Pull Request resolved: #27073

Test Plan: Try [this](3382984#commitcomment-35745287) snippet on iOS 13.1/13.2, the app should not crash anymore

Differential Revision: D18323679

Pulled By: cpojer

fbshipit-source-id: 3af7036a0e1d3811924e581c649b16e5a4667e83
@radko93
Copy link
Contributor

radko93 commented Nov 5, 2019

This is now fixed on 61 branch and on master.

@radko93 radko93 closed this as completed Nov 5, 2019
@sarthak-synclovis
Copy link

sarthak-synclovis commented Jan 10, 2020

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
Copy link

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

@vforvasile
Copy link

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

@octodhruv
Copy link

@vforvasile Nope - no websockets.

@unalkiran
Copy link

unalkiran commented Feb 19, 2020

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 !

  • iOS 13.3.1 (iPhone 11)
  • RN 0.61.5

can anyone help?

@terijyu
Copy link

terijyu commented Mar 11, 2020

This is causing serious issues for us as well @radko93

@hugw
Copy link

hugw commented Apr 29, 2020

@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
Copy link

skyfx64 commented Aug 12, 2020

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

@facebook facebook locked as resolved and limited conversation to collaborators Oct 3, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests