Content-Available background download using URLSession from cold launch fails with error: "Lost Connection to Background Transfer Service"
Number:rdar://FB7715286 Date Originated:26/05/2020
Status:Open Resolved:
Product:Foundation Product Version:
Classification:Bug Reproducible:Yes
I have already discussed this with a DTS engineer via "Apple Developer Technical Support". Repro steps are as follows:

- Set up app for content-available notifications which download a reasonably large payload (In our case content for our app as a tar.gz) using URLSession background downloads.
- Run app, without attaching to debugger and launch to fetch push token.
- Make sure app is terminated by the system, the easiest way to do this is to restart your device.
- Send content-available push notification to the app.
- Note that `applicationDidFinishLaunching` is called rather than the `performFetchWithCompletionHandler` app delegate method.
- Witness that when the `handleEventsForBackgroundURLSession` is called, and we get a response from the original background download session (Which is still alive in memory) it errors with "Lost Connection to Background Transfer Service".

Our logic works flawlessly if the update is NOT from a cold-launch, and the exact same code-path is taken by the app, so this is something caused by the fact it's a cold launch.

Attached are:
- Example project, with a README describing the problem again with additional repro steps. The example project uses logging and local notifications to help any testers know when content-available stuff happens in the background!
- A sysdiagnose taken ~9 minutes before the issue, and one ~3 minutes after it (It was really difficult to time these properly as content-available delivery is really flaky). Issue occurred at 13:42.
- Our own diagnostic logs taken from the application.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!