Skip to content

Migrate the Compose snippets from Coil 2 to Coil 3 - #1216

Merged
riggaroo merged 3 commits into
mainfrom
coil3-migration
Oct 26, 2026
Merged

riggaroo merged 3 commits into
mainfrom
coil3-migration

Conversation

@riggaroo

Copy link
Copy Markdown
Collaborator

Migrates the Compose snippets in compose/snippets from Coil 2 to Coil 3.

Coil 3 is multiplatform, so snippets that load images can also compile for the Compose Multiplatform (wasm) interactive previews (see #1215, which already moves AnimationQuickGuide.kt).

Changes

  • 8 files, imports only: coil.compose.* becomes coil3.compose.*, and coil.request.ImageRequest becomes coil3.request.ImageRequest. AsyncImage, rememberAsyncImagePainter and ImageRequest.Builder keep the same API. The one addition is import coil3.request.crossfade, because crossfade() is now an extension function (SharedElementCommonUseCaseSnippets.kt).
    • AnimationQuickGuide.kt, SharedElementCommonUseCaseSnippets.kt, LoadingImagesSnippets.kt, ComposeWithOtherLibraries.kt, PagerSnippets.kt, LazyListSnippets.kt, NestedScrollingItem.kt, TapAndPress.kt
  • Dependencies: compose/snippets replaces io.coil-kt:coil-compose:2.7.0 with io.coil-kt.coil3:coil-compose:3.6.3, plus coil-network-okhttp. Coil 3 doesn't load network URLs without a network module.
  • Not changed: the tv module still uses Coil 2 (3 files), so the coil-kt-compose catalog entry stays for now.

No code inside the snippet regions changes, only imports, so the DAC pages show the same code. The DAC quick guides that list io.coil-kt:coil-compose:2.6.0 as a dependency are updated in a separate CL.

Testing

  • ./gradlew :compose:snippets:compileDebugKotlin passes.
  • Runtime check: I temporarily rendered NestedScrollingRowsList in a Robolectric/Roborazzi test with real network URLs. Coil 3 fetched the images with OkHttp and drew them in the AsyncImages, the same result as Coil 2 on main.
    • Robolectric's native graphics can't run ImageDecoder on Coil's background threads; it aborts with Class not found: java/nio/ShortBuffer. So the test used Coil's BitmapFactoryDecoder. Coil 3 defaults to ImageDecoder on these API levels, so this is a limitation of the test environment, not something that affects devices. The test wasn't committed.

Coil 3 is multiplatform, so snippets that load images can also compile
for the Compose Multiplatform (wasm) interactive previews.

- Switch the coil.compose / coil.request imports in the 8 compose snippet
  files to coil3. AsyncImage and rememberAsyncImagePainter keep the same
  API; crossfade() is now an extension that needs its own import.
- Replace io.coil-kt:coil-compose with io.coil-kt.coil3:coil-compose and
  coil-network-okhttp in compose/snippets (Coil 3 needs a network module to
  load URLs). The tv module still uses Coil 2.
@riggaroo
riggaroo marked this pull request as ready for review October 23, 2026 12:14
@riggaroo
riggaroo requested a review from a team as a code owner October 23, 2026 12:14
@riggaroo
riggaroo requested a review from romanofranz October 23, 2026 12:14
@compose-devrel-github-bot

Copy link
Copy Markdown
Contributor

⚡ Jetpack Compose Performance Review

No Jetpack Compose performance issues were found in the changed code.

The changes in .gemini/pr_diff.patch consist solely of updating imports from Coil 2 (coil.*) to Coil 3 (coil3.*) across the touched files, introducing no performance regressions or violations of Jetpack Compose best practices.

@riggaroo
riggaroo enabled auto-merge (squash) October 23, 2026 12:16
@compose-devrel-github-bot

Copy link
Copy Markdown
Contributor

⚡ Jetpack Compose Performance Review

No Jetpack Compose performance issues were found in the changed code.

The changes in .gemini/pr_diff.patch consist solely of package import updates migrating Coil 2 (coil.*) to Coil 3 (coil3.*) across the touched files:

  • coil.compose.AsyncImage → coil3.compose.AsyncImage
  • coil.compose.rememberAsyncImagePainter → coil3.compose.rememberAsyncImagePainter
  • coil.request.ImageRequest → coil3.request.ImageRequest
  • coil3.request.crossfade

No newly introduced or modified code (+ lines) contains Jetpack Compose performance anti-patterns or regressions.

@riggaroo
riggaroo merged commit 1ccc9da into main Oct 26, 2026
14 checks passed
@riggaroo
riggaroo deleted the coil3-migration branch October 26, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants