Coil v2.0.0 Release Notes
Release Date: 2022-05-10 // almost 2 years ago-
โฌ๏ธ Coil 2.0.0 is a major iteration of the library and includes breaking changes. Check out the upgrade guide for how to upgrade.
- ๐ New: Introduce
AsyncImage
incoil-compose
. Check out the documentation for more info.
// Display an image from the network. AsyncImage( model = "https://example.com/image.jpg", contentDescription = null ) // Display an image from the network with a placeholder, circle crop, and crossfade animation. AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data("https://example.com/image.jpg") .crossfade(true) .build(), placeholder = painterResource(R.drawable.placeholder), contentDescription = stringResource(R.string.description), contentScale = ContentScale.Crop, modifier = Modifier.clip(CircleShape) )
- ๐ New: Introduce a public
DiskCache
API.- Use
ImageLoader.Builder.diskCache
andDiskCache.Builder
to configure the disk cache. - You should not use OkHttp's
Cache
with Coil 2.0. See here for more info. 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.- Existing disk caches will be cleared when upgrading to 2.0.
- Use
- ๐ The minimum supported API is now 21.
- 0๏ธโฃ
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 theirScale
auto-detected.
- This was changed to make
- Rework 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.- Add
ImageSource
, which allowsDecoder
s to readFile
s directly using Okio's file system API.
- Rework the Jetpack Compose integration:
rememberImagePainter
andImagePainter
have been renamed torememberAsyncImagePainter
andAsyncImagePainter
respectively.- Deprecate
LocalImageLoader
. Check out the deprecation message for more info.
- Disable generating runtime not-null assertions.
- If you use Java, passing null as a not-null annotated argument to a function will no longer throw a
NullPointerException
immediately. Kotlin's compile-time null safety guards against this happening. - This change allows the library's size to be smaller.
- If you use Java, passing null as a not-null annotated argument to a function will no longer throw a
- ๐จ
Size
is now composed of twoDimension
values for its width and height.Dimension
can either be a positive pixel value orDimension.Undefined
. See here for more info. - ๐
BitmapPool
andPoolableViewTarget
have been removed from the library. - ๐
VideoFrameFileFetcher
andVideoFrameUriFetcher
have been removed from the library. UseVideoFrameDecoder
instead, which supports all data sources. - ๐
BlurTransformation
andGrayscaleTransformation
are removed from the library. If you use them, you can copy their code into your project. - ๐ Change
Transition.transition
to be a non-suspending function as it's no longer needed to suspend the transition until it completes. - โ Add support for
bitmapFactoryMaxParallelism
, which restricts the maximum number of in-progressBitmapFactory
operations. This value is 4 by default, which improves UI performance. - โ Add support for
interceptorDispatcher
,fetcherDispatcher
,decoderDispatcher
, andtransformationDispatcher
. - โ Add
GenericViewTarget
, which handles commonViewTarget
logic. - โ Add
ByteBuffer
to the default supported data types. - ๐จ
Disposable
has been refactored and exposes the underlyingImageRequest
's job. - Rework the
MemoryCache
API. ImageRequest.error
is now set on theTarget
ifImageRequest.fallback
is null.Transformation.key
is replaced withTransformation.cacheKey
.- โก๏ธ Update Kotlin to 1.6.10.
- โก๏ธ Update Compose to 1.1.1.
- โก๏ธ Update OkHttp to 4.9.3.
- โก๏ธ Update Okio to 3.0.0.
๐ Changes from
2.0.0-rc03
:- Convert
Dimension.Original
to beDimension.Undefined
.- This changes the semantics of the non-pixel dimension slightly to fix some edge cases (example) in the size system.
- Load images with
Size.ORIGINAL
if ContentScale is None. - ๐ Fix applying
ImageView.load
builder argument first instead of last. - ๐ Fix not combining HTTP headers if response is not modified.
- ๐ New: Introduce