Skip to content

Fix regression of missing tinted backgrounds#3561

Merged
jonathanmos merged 2 commits into
developfrom
jmoskovich/fix-background-colors
Jun 22, 2026
Merged

Fix regression of missing tinted backgrounds#3561
jonathanmos merged 2 commits into
developfrom
jmoskovich/fix-background-colors

Conversation

@jonathanmos

Copy link
Copy Markdown
Member

What does this PR do?

RUM-16551 replaced GradientDrawable.mFillPaint reflection with the public getColor() API, which returns only the raw fill colour. AppCompat stores tints applied via DrawableCompat.setTintList() in the private Drawable.mTintFilter field, which is inaccessible on API 30+ (Android 11's catch-all hidden-API enforcement) and was also not read by the new code on API 24–28. This caused tinted button backgrounds to appear as invisible white ShapeWireframes instead of falling back to the image wireframe path.

Fix: return null from resolveGradientDrawable (Q mapper) and resolveGradientDrawableNPlus (M mapper) when drawable.colorFilter is null, restoring the image wireframe fallback which correctly renders the tinted appearance.

Expected:
Screenshot 2026-06-21 at 11 24 53

Regression:
Screenshot 2026-06-21 at 11 25 19

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.39%. Comparing base (5195501) to head (f1a1823).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...l/recorder/mapper/AndroidMDrawableToColorMapper.kt 20.00% 3 Missing and 1 partial ⚠️
...l/recorder/mapper/AndroidQDrawableToColorMapper.kt 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3561      +/-   ##
===========================================
+ Coverage    72.38%   72.39%   +0.01%     
===========================================
  Files          967      967              
  Lines        35712    35712              
  Branches      5972     5971       -1     
===========================================
+ Hits         25847    25851       +4     
- Misses        8190     8199       +9     
+ Partials      1675     1662      -13     
Files with missing lines Coverage Δ
...l/recorder/mapper/AndroidQDrawableToColorMapper.kt 50.00% <60.00%> (-1.11%) ⬇️
...l/recorder/mapper/AndroidMDrawableToColorMapper.kt 44.12% <20.00%> (-3.41%) ⬇️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos
jonathanmos marked this pull request as ready for review June 21, 2026 09:12
@jonathanmos
jonathanmos requested review from a team as code owners June 21, 2026 09:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1a1823661

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

val resolvedColor = resolveGradientFillColor(drawable) ?: return null
val resolvedColor = resolveGradientFillColor(drawable)
val colorFilter = resolveGradientColorFilter(drawable)
if (resolvedColor == null || colorFilter == null) return null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Don't drop default-mapped gradient backgrounds

When this mapper is used through ViewWireframeMapper (the default mapper for unmapped View/ViewGroup/decor views in TreeViewTraversal), returning null here does not take the image-wireframe fallback used by BaseAsyncBackgroundWireframeMapper; ViewWireframeMapper just returns emptyList() when shapeStyle is null. As a result, on API 29+ an ordinary solid <shape>/GradientDrawable background with no public colorFilter (and hidden tint filters as well) disappears from Session Replay instead of being captured. The N-P branch has the same unconditional no-filter check, so the fallback needs to be limited to mappers that can actually snapshot the background or keep returning resolvedColor when there is no accessible filter.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The null return when colorFilter == null is intentional: tints applied at the StateListDrawable container level don't propagate into the child GradientDrawable's own tint state, so there is no public API or reliable reflection path to distinguish "plain fill, safe to return a color" from "tinted but inaccessible."

The correct fix is probably in ViewWireframeMapper, adding the same image wireframe fallback that BaseAsyncBackgroundWireframeMapper already has. This is a significantly larger change than it appears: it touches payload size, privacy masking, and the async capture pipeline in ways that require careful design so I'm delaying it for a follow-up and won't fix it here.

@jonathanmos
jonathanmos merged commit 0d7a259 into develop Jun 22, 2026
27 checks passed
@jonathanmos
jonathanmos deleted the jmoskovich/fix-background-colors branch June 22, 2026 10:04
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.

5 participants