Re: Background download tasks intermittently stalling for 4 minutes
Re: Background download tasks intermittently stalling for 4 minutes
- Subject: Re: Background download tasks intermittently stalling for 4 minutes
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Tue, 15 Jul 2014 14:56:11 +0100
On 12 Jul 2014, at 00:44, Scott Hancher <email@hidden> wrote:
> According to Charles Proxy, even though I'm resuming all these tasks at basically the same time, only 3 seem to be in flight at any one time.
The daemon that manages the background downloads ("nsnetworkd" on current systems) is in control of which downloads it runs and at what time. IIRC current systems will only run 3 downloads at a time, but the actual algorithm for how it decides to run which tasks is both complex and liable to change. We talked about this a little in WWDC 2014 Session 707 "What's New in Foundation Networking" for more info, but that discussion only really scratches the surface.
<https://developer.apple.com/videos/>
I do have three concrete bits of advice for optimising downloads in an NSURLSession background session:
o The best approach is to download everything in one request. For example, if you can modify the server to zip up a bunch of items and send them to you in response to one resumable HTTP request, that's ideal.
o If that's not possible, you should start all your downloads at once, rather than start request N+1 in response to the completion of request N.
o When working with small requests, if you can reasonably expect the request to complete before your app gets suspended, it's fine to run the request in a default session (rather than a background session). You can use a UIApplication background task to keep your app from being suspended while the request runs.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden