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 in coil-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 and DiskCache.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 - except Vary 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.
    • ๐Ÿ‘ The minimum supported API is now 21.
    • 0๏ธโƒฃ ImageRequest's default Scale is now Scale.FIT.
      • This was changed to make ImageRequest.scale consistent with other classes that have a default Scale.
      • Requests with an ImageViewTarget still have their Scale auto-detected.
    • Rework the image pipeline classes:
      • Mapper, Fetcher, and Decoder have been refactored to be more flexible.
      • Fetcher.key has been replaced with a new Keyer interface. Keyer creates the cache key from the input data.
      • Add ImageSource, which allows Decoders to read Files directly using Okio's file system API.
    • Rework the Jetpack Compose integration:
      • rememberImagePainter and ImagePainter have been renamed to rememberAsyncImagePainter and AsyncImagePainter 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.
    • ๐Ÿ”จ Size is now composed of two Dimension values for its width and height. Dimension can either be a positive pixel value or Dimension.Undefined. See here for more info.
    • ๐Ÿšš BitmapPool and PoolableViewTarget have been removed from the library.
    • ๐Ÿšš VideoFrameFileFetcher and VideoFrameUriFetcher have been removed from the library. Use VideoFrameDecoder instead, which supports all data sources.
    • ๐Ÿšš BlurTransformation and GrayscaleTransformation 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-progress BitmapFactory operations. This value is 4 by default, which improves UI performance.
    • โž• Add support for interceptorDispatcher, fetcherDispatcher, decoderDispatcher, and transformationDispatcher.
    • โž• Add GenericViewTarget, which handles common ViewTarget logic.
    • โž• Add ByteBuffer to the default supported data types.
    • ๐Ÿ”จ Disposable has been refactored and exposes the underlying ImageRequest's job.
    • Rework the MemoryCache API.
    • ImageRequest.error is now set on the Target if ImageRequest.fallback is null.
    • Transformation.key is replaced with Transformation.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 be Dimension.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.