Repository navigation
fix(replay): Mask Coil 3.1+ AsyncImage in Compose - #6759
Merged
Merged
Conversation
Coil 3.1 moved the painter from ContentPainterElement to its Modifier.Node, so the reflective painter lookup failed and the node was not treated as an image. Treat a Painter-named modifier without a readable painter as a maskable image, keep *PainterElement names under R8, and run the replay unit tests across Coil 3 versions in CI. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
Contributor
PR risk: mediumFor commit Main concerns: reach, dependencies customers inherit, data sent to Sentry. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
📲 Install BuildsAndroid
|
getDeclaredField threw NoSuchFieldException for every Coil 3.1+ image on every frame, and the catch failed detekt. Search declaredFields instead, so no exception is created and the findPainter baseline entry is no longer needed. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
Drop the useCoil3 flag and its two tests. The existing image tests now expect both images. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
romtsn
marked this pull request as ready for review
November 25, 2026 12:51
romtsn
requested review from
0xadam-brown and
markushi
and removed request for
a team
November 25, 2026 12:51
The AGP matrix runs sentry-uitest-android as an R8 release build, but its Compose screen had no image. Add a Coil 3 AsyncImage and a ReplayTest that checks its area is one color in a replay frame. The app now uses Compose UI 1.10.2, the first version that lets R8 rename modifier elements, so the test fails without the PainterElement keep rule. Compose 1.10 needs minSdk 23. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
Override the minSdk 23 of the Compose 1.10 libraries in the manifest instead of raising the minSdk of the app. The UI tests run on API 30+ only. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
Compose UI 1.10 needs minSdk 23, and the UI tests run on API 30+ only. This replaces the manifest overrides for 12 libraries. Refs VULN-3400 Co-Authored-By: Claude <[email protected]>
3 tasks done
1 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Compose image masking now covers Coil 3.1+
AsyncImage. Before, these images were recorded unmasked even withmaskAllImageson.Compose image detection finds the first modifier whose class name contains
Painterand reads itspainterfield to decide if the image is maskable. Coil 3.1 moved the painter fromContentPainterElementto itsModifier.Node. The field lookup failed, and the node fell through to a generic, unmasked node.findPainter()is nowisMaskableImage(). APainter-named modifier without a readablepainterfield is treated as a maskable image. For Coil this matches what reading the painter would give: the painter is always theAsyncImagePainterwrapper, whichisMaskable()always masks, the same as Coil 2 and 3.0 today. The mask color is still sampled from the screenshot, so nothing else changes.painterfield is now found by name indeclaredFields, not withgetDeclaredField, which threw an exception for every Coil 3.1+ image on every frame. There is no catch anymore: any other reflection failure goes up tofromView, which masks the whole Compose view.-keepnames class **PainterElement. The existing rule keeps a class name only when the class has apainterfield, so R8 renamed Coil 3.1+ContentPainterElement(tohd0in the sample) and the name check failed in minified apps.CI:
compose-ui-matrix.ymlis nowreplay-dependency-matrix.yml, a GitHub matrix with two entries: the existing Compose UI matrix and a newcoil3Testmatrix that uses the samedependencyMatrixplugin (Coil 3.0.4, 3.1.0, 3.6.3). The unit tests use Coil 3.4.0, and the Compose 1.8.3 entry pins Coil 3.3.0 because newer versions need a newer Compose runtime. Coil 2 stays covered by the default unit tests, because it is a different artifact and package.UI tests: the AGP matrix runs
sentry-uitest-androidas an R8 release build. Its Compose screen now also shows a Coil 3AsyncImagewith a black/white bitmap, and the newReplayTest.composeCoilImageIsMaskedchecks that this area is one color in a replay frame. The app now uses Compose UI 1.10.2: from 1.10, Compose's own consumer rule lets R8 rename modifier elements (-keep,allowobfuscation,allowshrinking), so only on 1.10+ the test can fail without the new keep rule. Compose 1.10 needs minSdk 23, so the UI test app now uses minSdk 23, like the sample app. The UI tests run on API 30+ only, and the SDK still supports 21. The replay snapshot in the "Snapshot Testing" check shows the new, masked image.💡 Motivation and Context
💚 How did you test it?
ComposeMaskingOptionsTestactivity now renders a Coil 3AsyncImagenext to the Coil 2 one, and the existingmaskAllImageson/off tests expect both image nodes. Without the fix they fail withexpected 2 but was 1.ReplayTest.composeCoilImageIsMaskedfails without the code fix, fails without the keep rule (R8 renames the element toyj1), and passes with the full change. The other UI tests have the same results as onmain.AsyncImagethat shows a text bitmap): before the fix the text is readable in the replay frame. With the fix but without the new keep rule it is still readable. With the full change it is masked. A vectorImageon the same screen stays unmasked in all three builds.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
🤖 Generated with Claude Code