You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created ImagePrefetcher() and with the help of KingfisherOptionsInfo I have given the RetryStrategy but it seems the strategy not working.
What
func prefetchAllImages(completion: @escaping (Bool) -> Void) {
ImageCache.default.clearDiskCache()
ImageCache.default.clearMemoryCache()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
// Get all image URLs from ImageResourceUrl enum
let urls = ImageResourceUrl.allCases.map { $0.url }
let downloader = ImageDownloader(name: "custom")
downloader.downloadTimeout = 45
// Retry strategy: attempt up to 3 retries with a 1-second interval
let retryStrategy = DelayRetryStrategy(maxRetryCount: 3, retryInterval: .seconds(1))
// Set options with custom downloader and retry strategy
let kingFisherOptions: KingfisherOptionsInfo = [
.downloader(downloader),
.retryStrategy(retryStrategy)
]
// Prefetch images with completion handler
let prefetcher = ImagePrefetcher(urls: urls, options: kingFisherOptions, progressBlock: { skippedResources, failedResources, completedResources in
// You can use these counts for progress feedback
print("Ayush Completed: \(completedResources.count), Failed: \(failedResources.count), Skipped: \(skippedResources.count)")
}, completionHandler: { skippedResources, failedResources, completedResources in
if failedResources.isEmpty {
// All images downloaded successfully
completion(true)
} else {
// Some images failed to download
completion(false)
}
})
prefetcher.maxConcurrentDownloads = urls.count
prefetcher.start()
}
}
Reproduce
[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]
Other Comment
I can see in the ImagePrefetcher() class, retry startegy is not assigned to the manager
init(sources: [Source], options: KingfisherOptionsInfo?) {
var options = KingfisherParsedOptionsInfo(options)
prefetchSources = sources
pendingSources = ArraySlice(sources)
// We want all callbacks from our prefetch queue, so we should ignore the callback queue in options.
// Add our own callback dispatch queue to make sure all internal callbacks are
// coming back in our expected queue.
options.callbackQueue = .dispatch(prefetchQueue)
optionsInfo = options
let cache = optionsInfo.targetCache ?? .default
let downloader = optionsInfo.downloader ?? .default
manager = KingfisherManager(downloader: downloader, cache: cache)
}
The text was updated successfully, but these errors were encountered:
It looks like the retry strategy defined in KingfisherOptionsInfo is not utilized by ImagePrefetcher, as it is currently only used by KingfisherManager.shared.retrieveImage, and UIImageView().kf.setImage.
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
I have created ImagePrefetcher() and with the help of KingfisherOptionsInfo I have given the RetryStrategy but it seems the strategy not working.
What
Reproduce
[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]
Other Comment
I can see in the ImagePrefetcher() class, retry startegy is not assigned to the manager
The text was updated successfully, but these errors were encountered: