Re: WebDownloadDelegate delegate methods called on non-main thread
Re: WebDownloadDelegate delegate methods called on non-main thread
- Subject: Re: WebDownloadDelegate delegate methods called on non-main thread
- From: Jeff Johnson <email@hidden>
- Date: Mon, 29 Oct 2018 19:24:58 -0500
> On Oct 29, 2018, at 6:30 PM, Jens Alfke <email@hidden> wrote:
>
>> On Oct 29, 2018, at 3:34 PM, Nick Beadman <email@hidden>
>> wrote:
>>
>> When using the older WebView API to build a simple application that can
>> download files the thread that the WebDownloadDelegate methods are called on
>> changed between AppleWebKit/604.5.6 and AppleWebKit/605.1.15. I have
>> confirmed that the issue still occurs with r237410.
>
> Forwarding a callback from one thread/queue to another is simple, so this is
> easy enough to work around. Is it causing significant trouble for your code?
>
> I doubt Apple will fix this, since the old behavior was (IMO) bad — callbacks
> on the main thread can hurt app responsiveness. A good API will either allow
> the client to specify a thread/queue for callbacks, or just make callbacks on
> an unspecified thread and put the caller in charge of handling thread-safety.
> (The first approach is safer, the second faster.)
The old behavior is documented:
https://developer.apple.com/documentation/foundation/nsurldownloaddelegate
<https://developer.apple.com/documentation/foundation/nsurldownloaddelegate>
"Note that these delegate methods will be called on the thread that started the
asynchronous load operation for the associated NSURLDownload object."
There's no main thread requirement here, but there is a same thread
requirement. All the delegate methods should get called on the same thread,
whether that's main or some other thread.
Jeff
_______________________________________________
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