-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when cancelAll by SDWebImageManager. #809
Comments
Mi @maeji. We will look into this crash soon. |
can confirm crashing when canceling prefetcher.
If you guys need help testing with a real sample size, I can help by pushing out HEAD before SDWebImage cuts a release. Right now there are two show stopping crashes that took less than a minute to discover in a real world environment. |
@rromanchuk I have tried to reproduce this crash, but I doesn't occur to me. Could you help me with that? Do you have a scenario that works all the time? |
Also, could you please check using the latest HEAD for the other crash (#808), it should be fixed now. |
Yes #808 is fine, this bug is hard to reproduce, and I only see it frequently with 400+ active users, it's still my number one crash at the moment though. I reduced a majority of the crashes by removing calls to I will try and make the crash reproducible by prefetching and canceling but you can also see prefetching is canceled when given a new set of urls - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock {
[self cancelPrefetching]; // Prevent duplicate prefetch request
self.startedTime = CFAbsoluteTimeGetCurrent();
self.prefetchURLs = urls;
self.completionBlock = completionBlock;
self.progressBlock = progressBlock;
// Starts prefetching from the very first image on the list with the max allowed concurrency
NSUInteger listCount = self.prefetchURLs.count;
for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
[self startPrefetchingAtIndex:i];
}
} |
My guess is the best way to make it crash is by having active prefetching URLS, and interrupt them before they have finished It looks like I fixed the crash by changing - (void)cancel {
self.cancelled = YES;
if (self.cacheOperation) {
[self.cacheOperation cancel];
self.cacheOperation = nil;
}
if (self.cancelBlock) {
self.cancelBlock();
_cancelBlock = nil; // <------ fixes the crash
}
} |
I think I found the issue.
|
@rromanchuk Thanks for the support. Could you also check my latest fix (28109c4) against this crash? It shouldn't crash anymore (your clue that |
@bpoplauschi thanks! Let me rebuild with this commit, looks good though |
@rromanchuk did you get a chance to try this out? I want to release the patch asap. |
@bpoplauschi sending a release out now, should know soon |
looks like i'm still getting it :( Thread 0 Crashed: |
Until we can figure out the exact cause, made a temp fix (e95224b) with the suggested |
|
What version are you using? I'm asking because that code is a bit different now |
Bogdan, things seem OK with the patch, will let you know if I see anything Sent from my iPhone
|
Great, thanks. |
I seem to occasionally have this issue too. When I do: [[SDWebImageManager sharedManager] cancelAll]; I seem to get this exception: * Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSArrayM: 0x17024c390> was mutated while being enumerated.' |
this seems to fix it for me. Pull request: #838 |
same thing happens for cacheOperation setter.
|
It continue to crash. |
I can consistently get this to crash by prefetching different sets of images very quickly. I created an example project to show the crash with instructions in the README on how to trigger the crash also. It currently crashes for me 100% of the time https://github.com/dmiedema/SDWebImageCrashExample |
I had a pull request that fixed it for me. It was merged in but you have to grab it using the pod with a specific commit. It's not in 3.7.1 but will be in 3.7.2. Can you try in and see?— On Wed, Sep 3, 2014 at 3:54 AM, Daniel Miedema notifications@github.com
|
@justjimmy looks like referencing that commit fixes the issue in the example project. Thanks For anyone curious and reading this, until its put into a new release putting
in your Podfile will fix this particular issue. |
@dmiedema awesome. I think it'll be part of 3.7.2 whenever that is ready. |
@dmiedema any reason you are not using |
@rromanchuk theres no particular reason im not using Currently we've worked around the cancel all bug. i just didnt know it was resolved so i wanted to make a test project where it was reproducable. Its our most common crash for now, however with the work around & known fix it should become a non-issue. At least for us. |
Commit b59c2bb doesn't fix this. I just got it: |
Any idea when 3.1.2 is going to come out with this fix? We are trying to push an update to the SlideShare app tomorrow and this in our top 3 crashes. I think I'm just going to change our pod to reference the specific commit. Is 3587b8d still the right one to use to fix all these issues, including 798? |
I'm using 3.7.1 and I'm still getting crash. |
@timkoma this issues is not closed |
I think that in my case it is a concurency problem. I called [[SDWebImagePrefetcher sharedImagePrefetcher] prefetchURLs:url]; |
Conflicts: SDWebImage/SDWebImageManager.m
In tableView, I used SDWebImageManager. When I was try to cancel all download, My app was crashed at "self.cancelBlock = nil;" in SDWebImageManager.m (317 line).
I think that is released object problem.
SDWebImageCombinedOperation has cancelBlock. And It set like that,
Also it was copied by below function in code.
It was crashed at "self.cancelBlock = nil;" in cancel function in SDWebImageCombinedOperation. In my thought that was SDWebImageCombinedOperation was released before set nil.
When I removed "self.cancleBlock = nil;". It was working perfect. Is it right?
The text was updated successfully, but these errors were encountered: