iOS: BGProcessingTaskRequest gets killed due to high cpu usage

Viewed 264

I have an app that is requesting a BGProcessingTaskRequest -- this is the type of background activity that is encouraged to use if you have a process that is long running and advertised to even be able to retrain a machine learning model.

My background processing generally uses a DispatchQueue.global(qos: .background)) but I can't completely control this as I also for instance use a private Core Data background context.

However, my process gets killed due to cpu usage.

Event:            cpu usage
Action taken:     Process killed
CPU:              48 seconds cpu time over 55 seconds (87% cpu average), exceeding limit of 80% cpu over 60 seconds
CPU limit:        48s
Limit duration:   60s
CPU used:         48s
CPU duration:     55s
Duration:         55.24s
Duration Sampled: 40.95s
Steps:            22

Why is iOS imposing a CPU limit when the process is advertised as "A request to launch your app in the background to execute a processing task that can take minutes to complete.". The device was also plugged in during the crash.

The high cpu usage obviously is on purpose and also happens in a low-level Accelerate framework operation that I could not even throttle if I wanted to.

Any idea what I am doing wrong?

0 Answers
Related