Skip to content

Commit dd682c9

Browse files
committed
Performing cache callbacks from the ioQueue asynchronously.
- more appropriate than dispatch_main_sync_safe, since we’ll always be on the ioQueue when calling - prevents deadlock situation described in SDWebImage#625
1 parent 4b26a89 commit dd682c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

SDWebImage/SDImageCache.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *im
296296
[self.memCache setObject:diskImage forKey:key cost:cost];
297297
}
298298

299-
dispatch_main_sync_safe(^{
299+
dispatch_async(dispatch_get_main_queue(), ^{
300300
doneBlock(diskImage, SDImageCacheTypeDisk);
301301
});
302302
}
@@ -349,7 +349,7 @@ - (void)clearDiskOnCompletion:(void (^)())completion
349349
error:NULL];
350350

351351
if (completion) {
352-
dispatch_main_sync_safe(^{
352+
dispatch_async(dispatch_get_main_queue(), ^{
353353
completion();
354354
});
355355
}
@@ -486,7 +486,7 @@ - (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, NSUInte
486486
}
487487

488488
if (completionBlock) {
489-
dispatch_main_sync_safe(^{
489+
dispatch_async(dispatch_get_main_queue(), ^{
490490
completionBlock(fileCount, totalSize);
491491
});
492492
}

0 commit comments

Comments
 (0)