Avoid the strong retain during download decoding, this can make the download opearation fast to destroy and reduce memory peak, especially in progressive decoding
This commit is contained in:
parent
a521d0da77
commit
30618ce37d
|
@ -11,7 +11,6 @@
|
||||||
#import "SDInternalMacros.h"
|
#import "SDInternalMacros.h"
|
||||||
#import "SDWebImageDownloaderResponseModifier.h"
|
#import "SDWebImageDownloaderResponseModifier.h"
|
||||||
#import "SDWebImageDownloaderDecryptor.h"
|
#import "SDWebImageDownloaderDecryptor.h"
|
||||||
#import "SDAnimatedImage.h"
|
|
||||||
|
|
||||||
static NSString *const kProgressCallbackKey = @"progress";
|
static NSString *const kProgressCallbackKey = @"progress";
|
||||||
static NSString *const kCompletedCallbackKey = @"completed";
|
static NSString *const kCompletedCallbackKey = @"completed";
|
||||||
|
@ -395,7 +394,12 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
// keep maximum one progressive decode process during download
|
// keep maximum one progressive decode process during download
|
||||||
if (self.coderQueue.operationCount == 0) {
|
if (self.coderQueue.operationCount == 0) {
|
||||||
// NSOperation have autoreleasepool, don't need to create extra one
|
// NSOperation have autoreleasepool, don't need to create extra one
|
||||||
|
@weakify(self);
|
||||||
[self.coderQueue addOperationWithBlock:^{
|
[self.coderQueue addOperationWithBlock:^{
|
||||||
|
@strongify(self);
|
||||||
|
if (!self) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
UIImage *image = SDImageLoaderDecodeProgressiveImageData(imageData, self.request.URL, NO, self, [[self class] imageOptionsFromDownloaderOptions:self.options], self.context);
|
UIImage *image = SDImageLoaderDecodeProgressiveImageData(imageData, self.request.URL, NO, self, [[self class] imageOptionsFromDownloaderOptions:self.options], self.context);
|
||||||
if (image) {
|
if (image) {
|
||||||
// We do not keep the progressive decoding image even when `finished`=YES. Because they are for view rendering but not take full function from downloader options. And some coders implementation may not keep consistent between progressive decoding and normal decoding.
|
// We do not keep the progressive decoding image even when `finished`=YES. Because they are for view rendering but not take full function from downloader options. And some coders implementation may not keep consistent between progressive decoding and normal decoding.
|
||||||
|
@ -472,7 +476,12 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
} else {
|
} else {
|
||||||
// decode the image in coder queue, cancel all previous decoding process
|
// decode the image in coder queue, cancel all previous decoding process
|
||||||
[self.coderQueue cancelAllOperations];
|
[self.coderQueue cancelAllOperations];
|
||||||
|
@weakify(self);
|
||||||
[self.coderQueue addOperationWithBlock:^{
|
[self.coderQueue addOperationWithBlock:^{
|
||||||
|
@strongify(self);
|
||||||
|
if (!self) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// check if we already use progressive decoding, use that to produce faster decoding
|
// check if we already use progressive decoding, use that to produce faster decoding
|
||||||
id<SDProgressiveImageCoder> progressiveCoder = SDImageLoaderGetProgressiveCoder(self);
|
id<SDProgressiveImageCoder> progressiveCoder = SDImageLoaderGetProgressiveCoder(self);
|
||||||
UIImage *image;
|
UIImage *image;
|
||||||
|
|
Loading…
Reference in New Issue