Re: NSURLDownload notifies on wrong thread?
Re: NSURLDownload notifies on wrong thread?
- Subject: Re: NSURLDownload notifies on wrong thread?
- From: John Stiles <email@hidden>
- Date: Mon, 4 Jun 2007 14:20:23 -0700
BTW for Apple folks who might want to look this up, this is spelled
out in more detail at rdar://4992813
On Jun 4, 2007, at 2:16 PM, John Stiles wrote:
We had earlier found problems with memory leaks if we used
NSURLConnection from a thread other than the main thread. In
particular, the WebKit cache did not ever want to free up
resources, and it leaked memory until we disabled all caching. This
was not a problem for us, but we found that it worked fine if we
ran from the main thread so we assumed that NSURLConnection was not
thread safe.
I just checked the docs though, and found that NSURLConnection does
discuss behaviors that make it seem thread-safe (e.g. they say that
callbacks will occur on the thread which make certain calls).
Is there an official statement on this either way?
On Jun 4, 2007, at 1:46 PM, Brad Miller wrote:
It's a known bug. I filed a bug report on it in January 2005
(radar://3958646) and it was marked as a duplicate of radar://
3544581. File another report on it. The more reports the better.
NSURLConnection works correctly. I ended up using one instead of
NSURLDownload and then saving the document myself.
Brad
On Jun 3, 2007, at 7:24 PM, Doug Knowles wrote:
I'm so certain about this that I'm going to file a bug on it, but
I'm
posting it here to see if anyone else has seen it either knows
what I
might be doing wrong or how to work around it.
My app initiates an NSURLDownload fetch an RSS feed from a thread
other than the main thread. According to the NSURLDownload
documentation, the callbacks all occur on the thread that initiates
the request. My NSLog calls suggest otherwise:
2007-06-03 11:14:36.223 SLNavigator[6731] [rssListener-7]
initiateDownloadForFeed RSSFeed '':
http://macslash.org/rss/macslash.xml...
2007-06-03 11:14:36.231 SLNavigator[6731] [rssListener-7] ...started
download <NSURLDownload: 0x3828d0>
2007-06-03 11:14:36.235 SLNavigator[6731] [rssListener-7]
downloadDidBegin for <NSURLDownload: 0x3828d0>
2007-06-03 11:14:37.068 SLNavigator[6731] [Main Thread]
downloadDidFinish for <NSURLDownload: 0x3828d0>
The strings in brackets ("rssListener-7" or "Main Thread") are
strings
I attach to every thread so I know where things are happening. It's
pretty clear to me that I'm initiating the URL request on
"rssListener-7" and all of the notifications except for
downloadDidFinish are coming in to the same thread. The evidence is
prettty strong that the "...didFinish" notice is coming to the wrong
thread. My app fails because the "didFinish" handler tries to
access
an object that was created on the initiating thread.
Most of my NSURLDownload instances do not exhibit this problem. I
have evidence that wrong-thread notifications are occurring on
errors
(such as a request timeout) as opposed to successful downloads, if
that helps.
Any comments welcome. TIA.
Doug K;
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40blizzard.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40blizzard.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden