Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Crashed when prefetching images in a row.
You can test it on the latest Kingfisher codebase in ImagePrefetcherTests.swift.
func testPrefetchMultiTimes() {
testURLs.forEach { stub($0, data: testImageData) }
for _ in 0..<10000 {
let prefetcher = ImagePrefetcher(resources: testURLs)
prefetcher.start()
}
}
You may need to run it serveral times before the crashed happened.

Each prefetcher instance runs on an independent serial queue, while they are using the same image downloader. When downloading images, the downloader concurrently overwrites the same task's onTaskDone delegate's block, which cause a double free issue.
Thanks for reporting this. I will check it as soon as I can.
Should be fixed by making all prefetcher use the same queue.
Will the new version release in coming days?
5.1.1 was released.
Most helpful comment
5.1.1 was released.