1

Images are partially loaded and even though I have killed the and started back. Also this comes up rarely hence unable to reach out the exact issue. The image is not correcting itself and remains as such due to caching. But need a solution to fix this. A reference of code and image is attached.

extension UIImageView {

    public func sd_setImageWithURLWithFade(url: URL!, placeholderImage placeholder: UIImage? = nil) {

        self.sd_setImage(with: url, placeholderImage: placeholder, options: SDWebImageOptions.allowInvalidSSLCertificates)
        { (image, error, imageCacheType, imageUrl) in

            if let downLoadedImage = image {
                if imageCacheType == .none {
                    self.image = downLoadedImage
                }
            } else {
                self.image = placeholder
            }
        }
    }
}

enter image description here

Ishika
  • 2,187
  • 1
  • 17
  • 30

1 Answers1

0

This happens because, SDImage framework is storing the cached image for a particular image. So, now if due to some poor internet connection, if image gets downloaded partially and later you try to load the image from the same url, it will check for the existing image in cache and show you that image instead of the new image.

Thus, you are seeing the partially downloaded image even after you are re-running the app. If you delete that app and try running it again, and there will be no network issues, then it will download the full image and then onwards it will show you the fully downloaded image.

So, can say: that's the limitations to SDImageView.

Bhavin Kansagara
  • 2,866
  • 1
  • 16
  • 20
  • Hi, I do understand that issue is coming due to caching but what would be a viable fix to it – Ishika Aug 10 '18 at 06:12
  • You can try this as option SDWebImageRefreshCached, it will check and try to download the image again, if something wrong occurred while last download or if image changed at the same URL. Use this option, if not affecting the performance. – Bhavin Kansagara Aug 10 '18 at 07:26
  • The problem is the issue comes very rarely and am also not able to trace it back. So how should I check whether its fixed or not. Is there someway to track or reproduce this issue? – Ishika Aug 10 '18 at 08:33
  • yes, you can clear cache and memory in viewDidLoad method, while testing this. code to clear it is: https://stackoverflow.com/questions/39881566/how-to-clear-all-cached-images-loaded-from-sdwebimage – Bhavin Kansagara Aug 10 '18 at 08:35
  • and once the image start downloading, you can put iPhone to AirPlane mode to stop internet. Also, use the mobile data by setting network speed to 2G in your iphone settings. – Bhavin Kansagara Aug 10 '18 at 08:36
  • @Ishika Have you tried the suggestions and fixed your issues? – Bhavin Kansagara Aug 16 '18 at 12:13
  • I am still unable to reproduce back the issue – Ishika Aug 16 '18 at 12:22