Closed
Description
New Issue Checklist
- I have read and understood the CONTRIBUTING guideI have read the DocumentationI have searched for a similar issue in the project and found none
Issue Info
Info | Value |
---|---|
Platform Name | ios |
Platform Version | 8.0 |
SDWebImage Version | 3.8.0 |
Integration Method | cocoapods |
Xcode Version | e.g. Xcode 7.3.1 |
Repro rate | not clear from crash reports |
Repro with our demo prj | n/a |
Demo project link | n/a |
Issue Description and Steps
We have Fabric reporting a lot of the crashes
Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.
Crashed: NSOperationQueue 0x145699b0 :: NSOperation 0x145c13c0 (QOS: LEGACY)
0 libobjc.A.dylib 0x2393fa66 objc_msgSend + 5
1 CFNetwork 0x2478877f -[NSURLCache cachedResponseForRequest:] + 114
2 SDWebImage 0x23bd795 -[SDWebImageDownloaderOperation URLSession:task:didCompleteWithError:] (SDWebImageDownloaderOperation.m:407)
3 SDWebImage 0x23bb7f3 -[SDWebImageDownloader URLSession:task:didCompleteWithError:] (SDWebImageDownloader.m:306)
4 CFNetwork 0x24781505 __51-[NSURLSession delegate_task:didCompleteWithError:]_block_invoke170 + 76
5 Foundation 0x249a9679 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 8
6 Foundation 0x2490a5f3 -[NSBlockOperation main] + 146
7 Foundation 0x248fcbc9 -[__NSOperationInternal _start:] + 768
8 Foundation 0x249ab931 __NSOQSchedule_f + 192
9 libdispatch.dylib 0x23d12423 _dispatch_queue_drain$VARIANT$mp + 1758
10 libdispatch.dylib 0x23d11a61 _dispatch_queue_invoke$VARIANT$mp + 284
11 libdispatch.dylib 0x23d1415d _dispatch_root_queue_drain + 396
12 libdispatch.dylib 0x23d13fcd _dispatch_worker_thread3 + 96
13 libsystem_pthread.dylib 0x23ec9b29 _pthread_wqthread + 1024
14 libsystem_pthread.dylib 0x23ec9718 start_wqthread + 8
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
smogun commentedon Jun 30, 2016
We have also plenty of exactly the same crashes. It started to happen after updating to a version with NSURLSession
romk1n commentedon Jun 30, 2016
@smogun have you manage to reproduce it, I am wondering if that's relevant to the url query changes which were revered in 3.8.1 and if it fixes the crash?
asenchuk commentedon Jul 1, 2016
Confirm. After updating to 3.8.1 (from 3.7.6) getting lots of crashes with same reason:
Interesting that all crashes even don't have SDWebImage in the stack trace so found that ticket only after investigation what I updated since previous version so getting so many crashes. Don't think it's a coincidence.
romk1n commentedon Jul 1, 2016
i am just curios if it is safe to downgrade to 3.7.6
[-]crash in 3.8.0 from many users[/-][+]crash in 3.8.0 and 3.8.1 from many users[/+]bsjcho commentedon Jul 6, 2016
luckily I had this happen while I was debugging. here's the output of
bt all
. hopefully it's of some help.ryancrunchi commentedon Jul 7, 2016
Same here from Fabric/Crashlytics for multiple users :
nitikorndev commentedon Jul 7, 2016
I have the same issues too.

bpoplauschi commentedon Jul 7, 2016
I will look at this issue asap. Looks like more than an isolated issue
alexisbronchart commentedon Jul 12, 2016
I'm also having this issue. Critical. Downgraded to 3.7.6.
yshrkt commentedon Jul 20, 2016
I got same issue too.
#1623 looks like same issue.
GBoyadziev commentedon Jul 21, 2016
Same for me too. Next time it happens I will try to debug a bit and see if I can find out something useful.
bestwnh commentedon Aug 3, 2016
Hope anyone can try this #1623 (comment) , I just can't reproduce the crash by myself.
5 remaining items
eugene-manaev commentedon Aug 29, 2016
@bpoplauschi Yes, of course. Use this link to see crash: http://crashes.to/s/ddb48c8cc47
bpoplauschi commentedon Aug 29, 2016
Many thanks @DarkDarius. It seems my assumption was wrong. In your crashlog, there is no other thread working with the
NSURLCache
- dead end here, will need a new hypothesis.Another thing I tried was to pass nil to
[[NSURLCache sharedURLCache] cachedResponseForRequest:]
but it won't crash.Another idea is that somehow, the
NSURLRequest
gets deallocated, but that makes little sense since theSDWebImageDownloaderOperation
has a strong reference to theNSURLRequest
.romk1n commentedon Aug 29, 2016
@bpoplauschi here the one i found http://crashes.to/s/4af2fa1f4c7
bpoplauschi commentedon Aug 29, 2016
Thanks @romk1n
Updated code for #1608 #1623 - set a name for the download queue, avo…
bpoplauschi commentedon Sep 1, 2016
Guys, I'm in a bit of dead-end here. I need help. I've added 1 commit on master with a small change, could you try it and see if the issue still occurs? Also, if anyone can reproduce the issue constantly, could you create a small demo project so I can debug it properly? (maybe @bsjcho)
Note: I was able to simulate the same crashlog by using a deallocated instance of
NSURLRequest
passed to[NSURLCache cachedResponseForRequest:]
, but I forced that. Not able to properly reproduce with the current code.Improvement for #1608 and #1623 should solve the issue for most of th…
bpoplauschi commentedon Sep 5, 2016
I have made an attempt fix in e7bd5ab: Apparently there is a race condition on
NSURLCache
and we avoid making those checks unless necessary (basically we will query theNSURLCache
only whenSDWebImageRefreshCached
is used and the image cannot be cached by the system when it's too big or behind authentication). Will release a new version soon.bpoplauschi commentedon Sep 5, 2016
Guys, 3.8.2 is now available via CocoaPods, please try it out and let me know if the issue still happens or not.
kaspermunck commentedon Oct 20, 2016
@bpoplauschi Did you file a radar on that race condition in
NSURLCache
(if yes, can you provide a link to it so I can dupe)? Recently we have received similar crash reports that seem to happen internally inNSURLCache
-- not anSDWebImage
issue, don't worry :-)bpoplauschi commentedon Oct 20, 2016
@kaspermunck I did not create a radar, as I am not sure that is the cause. I'm waiting for people that had the issue and upgraded to comment back, if it's fixed. Basically, I only reduced the number of calls to
NSURLCache
kaspermunck commentedon Oct 20, 2016
Dug a little deeper (i.e. actually studied the documentation of NSURLCache) and unfortunately it looks like the race condition is expected in certain cases (read more here).
bpoplauschi commentedon Mar 10, 2017
Thanks to @zaczh, this issue will entirely go away in version 4.1.0.