BGProcessingTask executed, but app goes into suspended state after some seconds

We are seeing a strange behavior regarding BGProcessingTasks on recent iOS releases (tested on iOS 13.5.1, iOS 13.6, iOS 14 Beta 2).
The background task starts executing, but after a short period of time (sometimes just 5 seconds) the app goes into suspended date. The completion task or expiration task of the BackgroundProcessingTask is never called. We are seeing this behavior in production as well as in simulation( using: _simulateLaunchForTaskWithIdentifier)
On previous iOS 13 releases (can't exactly pinpoint the last version) it worked fine and the task got usually 5-10 minutes of background time and then ran either into the completion or expiration handler.

The issue is also reproducible using the Apple Sample App "Refreshing and Maintaining Your App Using Background Tasks" available at
https://developer.apple.com/documentation/backgroundtasks/refreshing_and_maintaining_your_app_using_background_tasks

Simplest way to reproduce the issue:
1) Launch the sample app
2) Bring the app to the background
3) Pause the debugger and simulate with
Code Block
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.example.apple-samplecode.ColorFeed.db_cleaning"]

4) Then continue the program execution.
5) The background task will start, but after some seconds the execution/log messages will stop and the app goes into suspended state.
6) To prove that its in suspended state: Switching the app into the foreground resumes execution and eventually completes the background task.

  • I still facing this issue. Do we have any solution?

Add a Comment

Replies

I was just experimenting with this and ran in to the same issue. However, it doesnt seem to happen for everyone so i'm wondering if its something specific in my setup. Did you ever get to the bottom of this issue?

thanks
I agree with hashbaby.
I have the same problem but cannot figure out why my app get suspended after a few seconds. Anyone have input in how to move forward?
We noticed BGProcessingTask is getting 300 seconds but that is not clock time. The task gets 300 seconds of CPU time, so if you have 10 threads executing within the task, and each thread will get about 30 seconds.

Apple markets this API as designed for long running task. That's not what it does, this API is severely broken and not implemented correctly.

can you pls tell me how to fix? i want to do some local tasks but didrecieveremotenotification stops calling because app is in suspended state .

Any update on this ? I'm facing the same issue