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

Background task creates the risk of termination #373

Open
zoolle opened this issue Nov 25, 2021 · 6 comments
Open

Background task creates the risk of termination #373

zoolle opened this issue Nov 25, 2021 · 6 comments

Comments

@zoolle
Copy link

zoolle commented Nov 25, 2021

I have opened the app and on initial load I create a set interval to send the location to backend every 5 seconds. I left the app in foreground and then in Xcode logs started to show me this

2021-11-25 14:41:34.367850+0000 Driver[3314:522530] [BackgroundTask] Background Task 5 ("RNBackgroundTimer"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this. 2021-11-25 14:42:02.242027+0000 Driver[3314:523175] [tcp] tcp_output [C8.1:3] flags=[R.] seq=1461532209, ack=806701271, win=2047 state=CLOSED rcv_nxt=806701271, snd_una=1461532132 2021-11-25 14:44:59.632334+0000 Driver[3314:523177] [tcp] tcp_input [C18.1:3] flags=[R] seq=2256668869, ack=0, win=0 state=LAST_ACK rcv_nxt=2256668869, snd_una=1943136650 2021-11-25 14:44:59.632865+0000 Driver[3314:523177] [tcp] tcp_input [C18.1:3] flags=[R] seq=2256668869, ack=0, win=0 state=CLOSED rcv_nxt=2256668869, snd_una=1943136650 2021-11-25 14:44:59.633033+0000 Driver[3314:523177] [tcp] tcp_input [C18.1:3] flags=[R] seq=2256668869, ack=0, win=0 state=CLOSED rcv_nxt=2256668869, snd_una=1943136650

Any idea why I get this and how can I avoid it?

@brunomartinezciompi
Copy link

Same

@guest2acute
Copy link

Same issue.

@Tim4497
Copy link

Tim4497 commented Mar 23, 2022

As far as I understand it you can just run code up to 30 seconds after the app enters background, and then you can only fire events again in a period of 15 minutes (also 30 seconds).

You could start the timer again with https://github.com/transistorsoft/react-native-background-fetch
which runs code every 15 minutes, but also it could be less depending on the hidden iOS background algorithm which depends on how often a App is used by the user (less use, less frequent background runtime)

Please correct me when I'm wrong, still figuring this background stuff out with react-native.

@dillonkelley
Copy link

Has anyone faced this warning and seen timer performance issues with iOS in production? I'm getting timer issues with iOS but works seemingly fine on Android.

@Irongade
Copy link

Irongade commented Aug 3, 2022

@Tim4497 So does this mean we have to use this package in conjunction with react-native-background-fetch? Or should we solely use react native background fetch for background tasks?

@Tim4497
Copy link

Tim4497 commented Aug 3, 2022

@Tim4497 So does this mean we have to use this package in conjunction with react-native-background-fetch? Or should we solely use react native background fetch for background tasks?

I used:

BackgroundFetch from 'expo-background-fetch';
TaskManager from 'expo-task-manager';

and

queue, { Worker } from 'react-native-job-queue';

in the end.

You can use them in bare rn projects, so no expo required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants