Merge branch 'master' into 4.x

# Conflicts:
#	CHANGELOG.md
#	Examples/SDWebImage Demo/MasterViewController.m
#	SDWebImage.podspec
#	SDWebImage/SDWebImageDownloader.m
#	SDWebImage/SDWebImageDownloaderOperation.m
#	WebImage/Info.plist
This commit is contained in:
Bogdan Poplauschi 2016-09-05 20:27:56 +03:00
commit 36e5e3c10d
3 changed files with 14 additions and 6 deletions

View File

@ -60,6 +60,11 @@
- Fix multiple requests for same image and then canceling one #883 + 8a78586
- Fixed #1444 and the master build thanks to [@kenmaz](https://github.com/kenmaz/SDWebImage/commit/5034c334be50765dfe4e97c48bcb74ef64175188)
## [3.8.2 Patch release for 3.8.0 on Sep 5th, 2016](https://github.com/rs/SDWebImage/releases/tag/3.8.2)
#### Fixes:
- Fixed #1608 #1623 #1644 Crash in `[NSURLCache cachedResponseForRequest:]` - the fix is actually avoiding to access `NSURLCache` which appears to generate a race condition. We only call it if necesarry (`SDWebImageRefreshCached` is used and the image cannot be cached by the system when it's too big or behind authentication)
## [3.8.1 Patch release for 3.8.0 on Jun 7th, 2016](https://github.com/rs/SDWebImage/releases/tag/3.8.1)

View File

@ -70,6 +70,7 @@
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
_downloadQueue = [NSOperationQueue new];
_downloadQueue.maxConcurrentOperationCount = 6;
_downloadQueue.name = @"com.hackemist.SDWebImageDownloader";
_URLOperations = [NSMutableDictionary new];
#ifdef SD_WEBP
_HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy];

View File

@ -67,7 +67,7 @@ typedef NSMutableDictionary<NSString *, id> SDCallbacksDictionary;
inSession:(nullable NSURLSession *)session
options:(SDWebImageDownloaderOptions)options {
if ((self = [super init])) {
_request = request;
_request = [request copy];
_shouldDecompressImages = YES;
_options = options;
_callbackBlocks = [NSMutableArray new];
@ -438,12 +438,14 @@ didReceiveResponse:(NSURLResponse *)response
completionBlock(nil, nil, error, YES);
}
} else {
if (![[NSURLCache sharedURLCache] cachedResponseForRequest:_request]) {
responseFromCached = NO;
}
if (completionBlocks.count > 0) {
if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) {
/**
* See #1608 and #1623 - apparently, there is a race condition on `NSURLCache` that causes a crash
* Limited the calls to `cachedResponseForRequest:` only for cases where we should ignore the cached response
* and images for which responseFromCached is YES (only the ones that cannot be cached).
* Note: responseFromCached is set to NO inside `willCacheResponse:`. This method doesn't get called for large images or images behind authentication
*/
if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached && [[NSURLCache sharedURLCache] cachedResponseForRequest:self.request]) {
for (SDWebImageDownloaderCompletedBlock completionBlock in completionBlocks) {
completionBlock(nil, nil, nil, YES);
}