Kingfisher: Update new image not work

Check List

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

Issue Description

I have an avatar and want to update it, after I upload a new image and get a new URL, then the setImage function still gives me the old one. This code is triggered whenever it has a new URL.

let url = URL(string: profile.avatar60 ?? "")
avatarImageView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "ic_profile_default"), options: [.transition(ImageTransition.fade(0.5))])

Then I cheat with this way to work (but some time it does not work)

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
      let url = URL(string: profile.avatar60 ?? "")
      me.avatarImageView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "ic_profile_default"), options: [.forceRefresh, .transition(ImageTransition.fade(0.5))])
})

So what is the exactly problem?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

@abdulKarim002

Hi, thanks for this. But the race condition should be already fixed.

Umm, it seems that I misunderstood the sanitizer warning. There was actually a race condition in reading without barrier. Now the race condition should be fixed in #790.

In addition, there is an Swift Access Race issue in the below function in ImageDownloader.swift

func clean(for url: URL) { barrierQueue.sync(flags: .barrier) { fetchLoads.removeValue(forKey: url) return } }