-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[iOS] Timing: Fixes timer when app get into background #24649
Conversation
Just a note that react-intl will set huge timeouts (sometimes days) for its |
@jacobp100 Eh, what do you mean? can you expand which issues you want to express? iOS can't run for days in background. |
I just wanted to highlight a popular library people use on React Native calls setTimeout with a delay that can last for days. If we wait for every set timeout by running the app in the background, it could, in some cases, be a drain on the battery. Not saying it shouldn't be merged, I just wanted to highlight one potential issue! |
@jacobp100 I don't know wether I get which issue you want to express. You mean it may has battery issue? Actually, we already support background timer in #23674(Many people have expressed a desire for background timer support on iOS ), and background task can only last most a few minutes, so we only can support background timer for a short time, if app not return to foreground, it will be killed by system. |
Sorry, thought this was adding the support. You're right, already there. Ignore me! 😄 |
Fixed #25083. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it. Thank you for the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @zhongwuzw in 3382984. When will my fix make it into a release? | Upcoming Releases |
Cheers! |
I have updated RCTTiming.m file with lasted code but still js code not work when app in background. thanks! |
…4649)" Co-Authored-By: �HackerMeo <minhtc@users.noreply.github.com>
)" This reverts commit 3382984.
…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
Summary: Related facebook#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: facebook#24649 Differential Revision: D15554451 Pulled By: cpojer fbshipit-source-id: a33f7afe6b63d1a4fefcb7098459aee0c09145da
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
Test Plan
Run code in background like the code below, console can log correctly.