Home > OS >  BGProcessingTaskRequest runs only for 295 seconds before the expiration handler is called on iOS 14.
BGProcessingTaskRequest runs only for 295 seconds before the expiration handler is called on iOS 14.

Time:10-12

We need to process a lot of data in the background for iOS and came across BGProcessingTaskRequest which is intended for tasks which may take minutes. However in practice, the task is always killed after exactly 295 seconds on my iOS 14.8 device.

Is this the most amount of background processing time we can expect on iOS or are there any other ways to increase the background execution time? If not, is it possible to chain the requests by scheduling the task again in it's own handler?

CodePudding user response:

As you know, they only promise that it “can run for minutes”. One would have hoped that setting the task’s requiresExternalPower, might increase the allotted time as the battery concerns are eliminated, but in my tests, the allotted time is still limited to roughly 5 minutes (tested in iOS 15).

As you suggest, you can schedule another processing request when time expires. In my experiments, though, this subsequent request took even longer before it started and expired even more quickly.

In short, you can chain requests as you suggest, but you are at the mercy of the OS.

  •  Tags:  
  • ios
  • Related