Coil v2.0.0-alpha01 Release Notes
Release Date: 2021-10-11 // over 2 years ago-
๐ Coil 2.0.0 is the next major iteration of the library and has new features, performance improvements, API improvements, and various bug fixes. This release may be binary/source incompatible with future alpha releases until the stable release of 2.0.0.
- Important: The minimum supported API is now 21.
- Important: Enable
-Xjvm-default=all
.- This generates Java 8 default methods instead of using Kotlin's default interface method support. Check out this blog post for more information.
- You'll need to add
-Xjvm-default=all
or-Xjvm-default=all-compatibility
to your build file as well. See here for how to do this.
- Important: Coil now has its own disk cache implementation and no longer relies on OkHttp for disk caching.
- This change was made to:
- Better support thread interruption while decoding images. This improves performance when image requests are started and stopped in quick succession.
- Support exposing
ImageSource
s backed byFile
s. This avoids unnecessary copying when an Android API requires aFile
to decode (e.g.MediaMetadataRetriever
). - Support reading from/writing to the disk cache files directly.
- Use
ImageLoader.Builder.diskCache
andDiskCache.Builder
to configure the disk cache. - You should not use OkHttp's
Cache
with Coil 2.0 as it can be corrupted if it's interrupted while writing to it. Cache-Control
and other cache headers are still supported - exceptVary
headers, as the cache only checks that the URLs match. Additionally, only responses with a response code in the range [200..300) are cached.- Support for cache headers can be enabled or disabled using
ImageLoader.Builder.respectCacheHeaders
. - Your existing disk cache will be cleared and rebuilt when upgrading to 2.0.
- This change was made to:
- Important:
ImageRequest
's defaultScale
is nowScale.FIT
- This was changed to make
ImageRequest.scale
consistent with other classes that have a defaultScale
. - Requests with an
ImageViewTarget
still have their scale autodetected.
- This was changed to make
- Significant changes to the image pipeline classes:
Mapper
,Fetcher
, andDecoder
have been refactored to be more flexible.Fetcher.key
has been replaced with a newKeyer
interface.Keyer
creates the cache key from the input data.- Adds
ImageSource
, which allowsDecoder
s to decodeFile
s directly.
- ๐
BitmapPool
andPoolableViewTarget
have been removed from the library. Bitmap pooling was removed because:- It's most effective on <= API 23 and has become less effective with newer Android releases.
- Removing bitmap pooling allows Coil to use immutable bitmaps, which have performance benefits.
- There's runtime overhead to manage the bitmap pool.
- Bitmap pooling creates design restrictions on Coil's API as it requires tracking if a bitmap is eligible for pooling. Removing bitmap pooling allows Coil to expose the result
Drawable
in more places (e.g.Listener
,Disposable
). Additionally, this means Coil doesn't have to clearImageView
s, which has can cause issues. - Bitmap pooling is error-prone. Allocating a new bitmap is much safer than attempting to re-use a bitmap that could still be in use.
- ๐จ
MemoryCache
has been refactored to be more flexible. - Disable generating runtime not-null assertions.
- If you use Java, passing null as a not-null annotated parameter to a function will no longer throw a
NullPointerException
immediately. If you use Kotlin, there is essentially no change. - This change allows the library's size to be smaller.
- If you use Java, passing null as a not-null annotated parameter to a function will no longer throw a
- ๐
VideoFrameFileFetcher
andVideoFrameUriFetcher
are removed from the library. UseVideoFrameDecoder
instead, which supports all data sources. - โ Adds support for
bitmapFactoryMaxParallelism
, which restricts the maximum number of in-progressBitmapFactory
operations. This value is 4 by default, which improves UI performance. - โ Adds support for
interceptorDispatcher
,fetcherDispatcher
,decoderDispatcher
, andtransformationDispatcher
. - ๐จ
Disposable
has been refactored and exposes the underlyingImageRequest
's job. - ๐ Change
Transition.transition
to be a non-suspending function as it's no longer needed to suspend the transition until it completes. - โ Add
GenericViewTarget
, which handles commonViewTarget
logic. - ๐
BlurTransformation
andGrayscaleTransformation
are removed from the library.- If you use them, you can copy their code into your project.
ImageRequest.error
is now set on theTarget
ifImageRequest.fallback
is null.Transformation.key
is replaced withTransformation.cacheKey
.ImageRequest.Listener
returnsSuccessResult
/ErrorResult
inonSuccess
andonError
respectively.- โ Add
ByteBuffer
s to the default supported data types. - โ Remove
toString
implementations from several classes. - โก๏ธ Update OkHttp to 4.9.2.
- โก๏ธ Update Okio to 3.0.0-alpha.10.