Skip to content

fix(replay): Mask Coil 3.1+ AsyncImage in Compose - #6759

Merged
romtsn merged 7 commits into
mainfrom
romtsn/fix/replay-coil3-masking
Nov 25, 2026
Merged

romtsn merged 7 commits into
mainfrom
romtsn/fix/replay-coil3-masking

Conversation

@romtsn

@romtsn romtsn commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Compose image masking now covers Coil 3.1+ AsyncImage. Before, these images were recorded unmasked even with maskAllImages on.

Compose image detection finds the first modifier whose class name contains Painter and reads its painter field to decide if the image is maskable. Coil 3.1 moved the painter from ContentPainterElement to its Modifier.Node. The field lookup failed, and the node fell through to a generic, unmasked node.

  • findPainter() is now isMaskableImage(). A Painter-named modifier without a readable painter field is treated as a maskable image. For Coil this matches what reading the painter would give: the painter is always the AsyncImagePainter wrapper, which isMaskable() always masks, the same as Coil 2 and 3.0 today. The mask color is still sampled from the screenshot, so nothing else changes.
  • The painter field is now found by name in declaredFields, not with getDeclaredField, which threw an exception for every Coil 3.1+ image on every frame. There is no catch anymore: any other reflection failure goes up to fromView, which masks the whole Compose view.
  • New consumer rule -keepnames class **PainterElement. The existing rule keeps a class name only when the class has a painter field, so R8 renamed Coil 3.1+ ContentPainterElement (to hd0 in the sample) and the name check failed in minified apps.

CI: compose-ui-matrix.yml is now replay-dependency-matrix.yml, a GitHub matrix with two entries: the existing Compose UI matrix and a new coil3Test matrix that uses the same dependencyMatrix plugin (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-android as an R8 release build. Its Compose screen now also shows a Coil 3 AsyncImage with a black/white bitmap, and the new ReplayTest.composeCoilImageIsMasked checks 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

  • resolves: VULN-3400

💚 How did you test it?

  • The ComposeMaskingOptionsTest activity now renders a Coil 3 AsyncImage next to the Coil 2 one, and the existing maskAllImages on/off tests expect both image nodes. Without the fix they fail with expected 2 but was 1.
  • All replay unit tests pass for the default variant, every Coil 3 matrix version and every Compose UI matrix version.
  • On an API 34 emulator, ReplayTest.composeCoilImageIsMasked fails without the code fix, fails without the keep rule (R8 renames the element to yj1), and passes with the full change. The other UI tests have the same results as on main.
  • On an API 34 emulator, with a non-debuggable, minified release build of the sample (PixelCopy strategy, temporary Coil 3 AsyncImage that 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 vector Image on the same screen stays unmasked in all three builds.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

🤖 Generated with Claude Code

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]>
@linear-code

linear-code Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

VULN-3400

JAVA-851

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit f3eaeb3.

Main concerns: reach, dependencies customers inherit, data sent to Sentry.

Rules that block low also fired:

  • R5: dependencies or bundled SDK versions changed: gradle/libs.versions.toml
  • R6: build or release configuration changed: .github/workflows/replay-dependency-matrix.yml, gradle/coil3-versions.json, gradle/compose-ui-versions.json, gradle/libs.versions.toml, sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts and 2 more

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.65.1 (1) release

⚙️ sentry-android Build Distribution Settings

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]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
@romtsn romtsn added the sanity-check PR needs a lightweight review for obvious issues label Nov 25, 2026
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]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
@romtsn
romtsn marked this pull request as ready for review November 25, 2026 12:51
@romtsn
romtsn requested review from a team and adinauer as code owners November 25, 2026 12:51
@romtsn
romtsn requested review from 0xadam-brown and markushi and removed request for a team November 25, 2026 12:51
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
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]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026

@markushi markushi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, LGTM!

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]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
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]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
@romtsn
romtsn merged commit 76d8a3c into main Nov 25, 2026
53 checks passed
@romtsn
romtsn deleted the romtsn/fix/replay-coil3-masking branch November 25, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants