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
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.
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.