Open bohdany-cricut opened 7 months ago
I just ran into this as well.
It appears to be caused in KingfisherManager.retrieveImageFromCache
cacheType
as .none
since the processed image was missing from the cacheIt fails to find the processed image since kingfisher appends the processor identifier to the cache key when saving and restoring.
This is probably expected behaviour since the final image wasn't found in the cache so retrieving it could take long enough that the fade is needed.
My current workaround is to make a MockImageCache
for use in the tests, which always discards the options
when retrieving an image since the options are used to modify the cache key.
The one downside with this approach is it'll bypass running any processor on the image, so your snapshots wont accurately test whether the correct processor is being used.
private final class MockImageCache: ImageCache {
override func imageCachedType(
forKey key: String,
processorIdentifier identifier: String = DefaultImageProcessor.default.identifier
) -> CacheType {
.memory
}
override func retrieveImage(
forKey key: String,
options: KingfisherParsedOptionsInfo,
callbackQueue: CallbackQueue = .mainCurrentOrAsync,
completionHandler: ((Result<ImageCacheResult, KingfisherError>) -> Void)?
) {
var options = options
options.processor = DefaultImageProcessor.default
super.retrieveImage(
forKey: key,
options: options,
callbackQueue: callbackQueue,
completionHandler: completionHandler
)
}
}
Check List
Issue Description
What
The documentation for the
fade
transition says thatBut in one particular case it seems to still being applied - when it's used with
downsampling
. I noticed that my snapshot tests started to fail after I addeddownsampling
to theKFImage
I use. Upon closer look, it turned out to be that images now don't appear instantly but with a slight delay and a fade transition animation. Here's the image setup:And here is the cache setup:
Reproduce
Use KFImage with
fade
anddownsampling
applied along with cache being set up. Upon retrieval images from the cachefade
transition is still being applied.Other Comment
I did try using
.cacheOriginalImage
but it did not make any difference.