Kingfisher: Cached images, reload problem.

Created on 16 Aug 2019  Â·  4Comments  Â·  Source: onevcat/Kingfisher

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

Loading problem on cached images.

What

If i load the image very quickly in tableview, i get notCurrentSourceTask error. Additional info, my table view, can be reloaded frequently. Why is this error caused ?

[Tell us about the issue]
imageSettingError(reason: Kingfisher.KingfisherError.ImageSettingErrorReason.notCurrentSourceTask(result: Optional(Kingfisher.RetrieveImageResult(image: , {1600, 1067}, cacheType: Kingfisher.CacheType.disk, source: Kingfisher.Source.network(myImageURL))), error: nil, source: Kingfisher.Source.network(myImageURL)))

Most helpful comment

That means a new image downloading task is started before the previous one has a chance to finish. When the previous one finishes, it will trigger its completion handler with this error.

Kingfisher will handle the case correctly and set the image which is loaded lastly. So in most cases, you can just ignore this error.

All 4 comments

That means a new image downloading task is started before the previous one has a chance to finish. When the previous one finishes, it will trigger its completion handler with this error.

Kingfisher will handle the case correctly and set the image which is loaded lastly. So in most cases, you can just ignore this error.

Thanks, yes, you are right. I sloved it like this.

self.photo.kf.setImage(with: viewModel.photoURL, placeholder: viewModel.dummyImage, options: options, progressBlock: nil) { [weak self] result in switch result { case .success: break: case .failure(let error): if !error.isTaskCancelled && !error.isNotCurrentTask { self?.photo.image = Images.failImage } } }

Good to know it. But if this is what you want to do (setting a failure image), maybe this would be a more elegant solution: https://github.com/onevcat/Kingfisher/blob/master/Sources/General/KingfisherOptionsInfo.swift#L182-L185

Awesome, thank you for your response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  Â·  3Comments

OhKai picture OhKai  Â·  4Comments

Tarpsvo picture Tarpsvo  Â·  5Comments

freak4pc picture freak4pc  Â·  3Comments

kbpontius picture kbpontius  Â·  3Comments