Re: URLSession on iOS 10
Re: URLSession on iOS 10
- Subject: Re: URLSession on iOS 10
- From: Rick Mann <email@hidden>
- Date: Wed, 23 Nov 2016 02:11:15 -0800
> On Nov 23, 2016, at 01:01 , Quinn The Eskimo! <email@hidden> wrote:
>
>
> On 23 Nov 2016, at 00:47, Shawn Erickson <email@hidden> wrote:
>
>> I throttle things using an operation queue set to 10 current operations …
>
> To be clear, NSURLSession was designed to /not/ require the client to throttle requests. You should be able to dump as many requests as you like into a session and NSURLSession throttles them internally.
>
> The only place where this doesn’t hold true is background sessions, where the bookkeeping associated with the background session means that starting many thousands of requests engenders a noticeable performance penalty. In general, I recommend that you use fewer, larger requests in a background session, as explained by the following post.
>
> <https://forums.developer.apple.com/thread/14853>
>
> Now, if you want to throttle requests for other reasons that’s absolutely fine. However, you shouldn't /need/ to do that.
>
> * * *
>
> @Rick Mann, It seems like something is going wrong with NSURLSession here. I’d appreciate you filing a bug about this. It’d be great if you could include a small test project that illustrates the issue.
>
> <https://developer.apple.com/bug-reporting/>
>
> Please post the bug number, just for the record.
Radar 29280854
It was part of my original post.
As to providing a small sample app to reproduce the behavior, I don't think I can do that. The bug has instructions for reproducing it using our app in the App Store, but it would take me time to write a sample, and I really need to get this workaround out.
I suspect if you just start a URLSession with 3000 downloadTasks of the same URL, a 50KB image say, then it will trigger (you can set the host connections to 24, but that shouldn't be necessary). In the completion block for each download, move the file to a directory. Might want to give them a random name so they don't overwrite one another.
If it doesn't trigger, create 10 of these URL sessions simultaneously.
As to doing all this with background sessions, I really would like to be able to do that. Unfortunately, there is simply no way we can do this as fewer, larger files. Our web viewer only downloads a few of these files at a time. I'm downloading them all because our iOS app is able to cache the models for offline viewing. Providing both the individual files via the CDN and, say, zip files of collections of the individual files would double our storage costs and our CDN cache size (and cost).
iOS should be able to deal with the metadata for thousands of files to be downloaded in the background. Now, if you tell me that iOS will wake my app in the background when it's done downloading a smaller batch, and allow me to enqueue another batch for download, then I can probably throttle the background task. But that means I write throttling code anyway, and duplicate a bunch of work.
I think you'll find that as 3D data becomes more prevalent (as more and more 3D cameras come on the market), the number of files that need to be downloaded to support a single 3D "movie" will increase, at least in cases where the models are also viewed online and users don't want to wait for lengthy downloads before they can start exploring. Unlike a regular movie, you don't go through a 3D model in any specific order; it's random-access, so you need rapid access to all the data at once.
Anyway, thanks for helping me troubleshoot this. If I can come up with a sample project, I will, but I'm currently swamped implementing throttling, and once that's done, I'll have much less incentive to do the sample. For once, Apple is going to have to reproduce a bug on its own.
:/
--
Rick Mann
email@hidden
_______________________________________________
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