Fix the assert case when loader callback nil image data

This commit is contained in:
DreamPiggy 2022-06-25 23:41:36 +08:00
parent 69acd5a158
commit 071a8934e3
2 changed files with 3 additions and 1 deletions

View File

@ -568,7 +568,8 @@ static id<SDImageLoader> _defaultImageLoader;
// thumbnail check
// This exist when previous thumbnail pipeline callback into next full size pipeline, because we share the same URL download but need different image
// Actually this is a hack, we attach the metadata into image object, which should design a better concept like `ImageInfo` and keep that around
BOOL shouldRedecodeFullImage = cacheType == SDImageCacheTypeNone;
// Redecode need the full size data (progressive decoding or third-party loaders may callback nil data)
BOOL shouldRedecodeFullImage = originalData && cacheType == SDImageCacheTypeNone;
if (shouldRedecodeFullImage) {
// If the retuened image decode options exist (some loaders impl does not use `SDImageLoaderDecode`) but does not match the options we provide, redecode
SDImageCoderOptions *returnedDecodeOptions = originalImage.sd_decodeOptions;

View File

@ -265,6 +265,7 @@
NSUInteger defaultLimitBytes = SDImageCoderHelper.defaultScaleDownLimitBytes;
SDImageCoderHelper.defaultScaleDownLimitBytes = 1000 * 1000 * 4; // Limit 1000x1000 pixel
// From v5.5.0, the `SDWebImageScaleDownLargeImages` translate to `SDWebImageContextImageThumbnailPixelSize`, and works for progressive loading
[SDImageCache.sharedImageCache removeImageFromDiskForKey:originalImageURL.absoluteString];
[SDWebImageManager.sharedManager loadImageWithURL:originalImageURL options:SDWebImageScaleDownLargeImages | SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
expect(image).notTo.beNil();
expect(image.size).equal(CGSizeMake(1000, 1000));