5.0.0 - Reborn
Although most APIs are compatible, Kingfisher 5 contains breaking changes.
To know what's new in Kingfisher 5, check this wiki page. Depending on your use cases of Kingfisher 4, it may take no effort or at most several minutes to fix errors and warnings after upgrading. The upgrading should be easy enough for most users. Follow the Kingfisher 5.0 Migration Guide to migrate to the new version.
Add
- Add
Result
type to Kingfisher. Now all callbacks in Kingfisher are usingResult
instead of tuples. This is more future-friendly and provides a modern way to make error handling better. - Make
KingfisherError
much more elaborate and accurate. Instead of simply provides the error code, nowKingfisherError
contains error reason and necessary associated values. It will help to understand and track the errors easier. - Better cache management by separating memory cache and disk cache to their own storages. Now you can use
MemoryStorage
andDiskStorage
as theImageCache
backend. - Image cache of memory storage would be purged automatically in a certain time interval. This reduce memory pressure for other parts of your app.
- The
ImageCache
is rewritten from scratch, to get benefit from new createdMemoryStorage
andDiskStorage
. At the same time, this hybrid cache abstract keeps most API compatibility from the earlier versions. - Now the
ImageCache
can receive only rawData
object and cache it as needed. - A
KingfisherParsedOptionsInfo
type to parseKingfisherOptionsInfoItem
s in related API. This improves reusability and performance when handling options in Kingfisher. - An option to specify whether an image should also prefetched to memory cache or not.
- An option to make the disk file loading synchronously instead of in its own I/O queue.
- Options to specify cache expiration for either memory cache or disk cache. This gives you a chance to control cache lifetime in a per-task grain size.
- Add a default maximum size for memory cache. Now only at most 25% of your device memory will be used to kept images in memory. You can also change this value if needed.
- An option to specify a processing queue for image processors. This gives your flexibility if you want to use main queue or if you want to dispatch the processing to a different queue.
- A
DownsamplingImageProcessor
for downsampling an image to a given size before loading it to memory. - Add
ImageDataProvider
protocol to make it possible to provide image data locally instead of downloading from network. Several concrete types are provided to load images from data format. UseLocalFileImageDataProvider
to load an image from a local disk path,Base64ImageDataProvider
to load image from a Base64 string representation andRawImageDataProvider
to provide a rawData object
. - A general
Source
protocol to define from where the image should be loaded. Currently, we support to load an image fromImageDataProvider
or from network now.
Fix
- Now CommonCrypto from system is used to calculate file name from cache key, instead of using a customized hash algorithm.
- An issue which causes
ImageDownloader
crashing when a lot of downloading tasks running at the same time. - All operations like image pretching and data receiving should now be performed in non-UI threads correctly.
- Now
KingfisherCompatible
uses struct forkf
namespacing for better performance.