Kingfisher icon indicating copy to clipboard operation
Kingfisher copied to clipboard

Image loading fails with notCurrentSourceTask even if the task is still valid

Open tfonfara opened this issue 5 years ago • 2 comments

Check List

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

Issue Description

What

In my app I have a collection view with 3 cells (one image per cell). The data of this collection view will be reloaded 3 times in a very short time. This causes Kingfisher to fail setting the image with .notCurrentSourceTask even if the cell is still the correct one (meaning the task identifier is still "valid").

2019-09-26 10:31:06.440 setImage <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 27> <url: URL1>
2019-09-26 10:31:06.442 setImage <UIImageView: 0x7ffcfbe82510> <taskIdentifier: 28> <url: URL2>
2019-09-26 10:31:06.444 setImage <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 29> <url: URL3>
2019-09-26 10:31:06.446 cancel <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 29>
2019-09-26 10:31:06.447 setImage <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 30> <url: URL1>
2019-09-26 10:31:06.447 cancel <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 27>
2019-09-26 10:31:06.447 setImage <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 31> <url: URL2>
2019-09-26 10:31:06.448 cancel <UIImageView: 0x7ffcfbe82510> <taskIdentifier: 28>
2019-09-26 10:31:06.448 setImage <UIImageView: 0x7ffcfbe82510> <taskIdentifier: 32> <url: URL3>
2019-09-26 10:31:06.525 cancel <UIImageView: 0x7ffcfbe82510> <taskIdentifier: 32>
2019-09-26 10:31:06.526 setImage <UIImageView: 0x7ffcfbe82510> <taskIdentifier: 33> <url: URL1>
2019-09-26 10:31:06.526 cancel <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 30>
2019-09-26 10:31:06.527 setImage <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 34> <url: URL2>
2019-09-26 10:31:06.528 cancel <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 31>
2019-09-26 10:31:06.529 setImage <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 35> <url: URL3>
2019-09-26 10:31:06.537 error <UIImageView: 0x7ffcfbe7bce0> <taskIdentifier: 35> Error while downloading image from url: URL3: imageSettingError(reason: Kingfisher.KingfisherError.ImageSettingErrorReason.notCurrentSourceTask(result: Optional(Kingfisher.RetrieveImageResult(image: <UIImage:0x60000333d440 anonymous {1077, 606}>, cacheType: Kingfisher.CacheType.none, source: Kingfisher.Source.network(VarysCore.UrlResource))), error: nil, source: Kingfisher.Source.network(UrlResource)))
2019-09-26 10:31:06.554 error <UIImageView: 0x7ffcfbe866a0> <taskIdentifier: 34> Error while downloading image from url: URL2: imageSettingError(reason: Kingfisher.KingfisherError.ImageSettingErrorReason.notCurrentSourceTask(result: Optional(Kingfisher.RetrieveImageResult(image: <UIImage:0x60000334d7a0 anonymous {1077, 606}>, cacheType: Kingfisher.CacheType.none, source: Kingfisher.Source.network(VarysCore.UrlResource))), error: nil, source: Kingfisher.Source.network(UrlResource)))

In the log file I logged imageView.kf.setImage(), imageView.kf.cancelDownloadTask() and the error from the setImage completion handler. As you can see for each cell the same url is being loaded multiple times before the loading succeeds. The task identifier (imageView.kf.taskIdentifier) for the failing image views should be still "there", no cancel or set image calls happened meanwhile.

tfonfara avatar Sep 26 '19 08:09 tfonfara

I solved it. It's don't redownload when url is equal. You can ignore it. Source: https://github.com/onevcat/Kingfisher/issues/1262#issuecomment-527268134

yunustek avatar Oct 20 '19 22:10 yunustek

I solved it. It's don't redownload when url is equal. You can ignore it. Source: #1262 (comment)

i am facing same, How have you solved it?

asheesh-verma avatar Mar 21 '23 12:03 asheesh-verma