BGContinuedProcessingTask compatibility with background URLSession

My app does really large uploads. Like several GB. We use the AWS SDK to upload to S3.

It seemed like using BGContinuedProcessingTask to complete a set of uploads for a particular item may improve UX as well as performance and reliability.

When I tried to get BGContinuedProcessingTask working with the AWS SDK I found that the task would fail after maybe 30 seconds. It looked like this was because the app stopped receiving updates from the AWS upload and the task wants consistent updates. The AWS SDK always uses a background URLSession and this is not configurable. I understand the background URLSession runs in a separate process from the app and maybe that is why progress updates did not continue when the app was in the background.

Is it expected that BGContinuedProcessingTask and background URLSession are not really compatible? It would not be shocking since they are 2 separate background APIs.

Would the Apple recommendation be to use a normal URLSession for this, in which case AWS would need to change their SDK?

Or does Apple think that BGContinuedProcessingTask should just not be used with uploads? In other words use an upload specific API.

Thanks!

I’m not aware of any fundamental incompatibility between continued processing tasks and URLSession background sessions. However, as you say, it’s not hard to imagine such a problem arising. The combination is not something you’d normally do because background sessions are usually only relevant if your app is eligible for suspension.

Still, the combination does make sense in some circumstances. Imagine you’re building a video app and you want to export a file and upload it. Except it’s not one file, but multiple, say with different resolutions. It’d make sense to use a continued processing task for this, and it’d also make sense for you to use a background session to upload a file once you’ve finished processing it. That way, if the user (or OS) cancels your continued processing task, then at least the files that you’ve exported so far will continue to upload.

Can you reproduce this without the third-party SDK? That’d rule out there being something in the SDK that’s triggering this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks!

I had tested without the AWS SDK and instead did simple, fake, local work and BGContinuedProcessingTask worked reliably.

I will try to test upload and BGContinuedProcessingTask without the AWS SDK so that I can use a normal or background URLSession to see if that is the difference.

BGContinuedProcessingTask compatibility with background URLSession
 
 
Q