SDWebImage: Is there a BUG that sd_setImageWithURL completed with a wrong image?

[aActionIV sd_setImageWithURL:tryURL
             placeholderImage:holderImg
                      options:SDWebImageRetryFailed | SDWebImageLowPriority
                     progress:^(NSInteger receivedSize, NSInteger expectedSize)
     {
         if (expectedSize > 0)
         {
             float progress = receivedSize / (float)expectedSize;
             [loadingIndicator setProgress:MAX(MIN(1, progress), 0) animated:YES];
         }
     }
                        completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
     {
         [loadingIndicator removeFromSuperview];

         if (error)
         {
             NSLog(@"%@", error);
         }
         else
         {
         }
     }];

I have some UIImageView that using sd_setImageWithURL to load images. But after pod update SDWebImage to 3.7.2, sometimes one UIImageView will show wrong image that belongs to other URL. Just like two UIImageView exchange their images. And when I change SDWebImage to 3.7.1, everything is OK. So weird! Now the question, Is there a BUG that sd_setImageWithURL completed with a wrong image?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 31 (10 by maintainers)

Most upvoted comments

Well, my solution also worked. 😃 - I don’t think it should be necessary though. I’d expected SDWebImage to cancel the previous download if I start a new one on the same UIImageView (or is there a case where you wouldn’t want to have this behavior?). The solution with manually resetting works good in general I think. Would need to mention it in the docs (even if it’s only until it is fixed).

I think this is what happend in my case:

  • Start table view
  • First cell is loaded
  • First image is requested
  • First image is downloaded, inserted and cached (<- this is important I think for it to be reproducible)
  • Scroll down
  • Same cell is reused
  • New image is requested
  • Scroll up to first cell
  • First image is requested from cache and inserted immediately
  • Second image is downloaded and replaces the first image that was loaded from cache
  • Now we have the second image in the first cell

But again, I don’t think it’s super urgent to fix this since the workaround works pretty good even without accessing the source.