I have been experimenting with the BGContinuedProcessingTask API recently (and published sample code for it https://github.com/infinitepower18/BGContinuedProcessingTaskDemo)
I have noticed that if I lock the phone, the code that runs as part of the task stops executing. My sample code simply updates the progress each second until it gets to 100, so it should be completed in 1 minute 40 seconds. However, after locking the phone and checking the lock screen a few seconds later the progress indicator was in the same position as before I locked it.
If I leave the phone locked for several minutes and check the lock screen the live activity says "Task failed".
I haven't seen anything in the documentation regarding execution of tasks while the phone is locked. So I'm a bit confused if I encountered an iOS bug here?
I haven't seen anything in the documentation regarding execution of tasks while the phone is locked. So I'm a bit confused if I encountered an iOS bug here?
It's possible there's a bug on our side as well, but the issue in your code is that you never call setTaskCompleted(success:) to finish the task. As far as the system is concerned, your task isn't "done" until you mark it complete, regardless of progress. That means it eventually fails due to lack of progress once your loop stops and the block returns.
Is it finishing properly while the device is unlocked? That's actually what's odd here to me.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware