Skip to content

RUM-9527: Defer drawable copy to work thread in Session Replay#2723

Merged
ambushwork merged 1 commit into
developfrom
yl/fix-drawable-utils-crash
Jun 13, 2025
Merged

RUM-9527: Defer drawable copy to work thread in Session Replay#2723
ambushwork merged 1 commit into
developfrom
yl/fix-drawable-utils-crash

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

This PR defers the drawable copy from main thread to work thread in Session Replay to fix the crash when Android View wants to draw the original drawable on UI thread.

Why the crash happens?

To draw the drawable to generate bitmap for Session Replay image wireframe, we will copy the drawable in case of any impact of the original one, for most of the implementations of Drawable it has no problem, except MaterialShapeDrawable.

MaterialShapeDrawable holds an singleton of ShapeAppearancePathProvideron main thread, if we copy the drawable on main thread, the same path held by this singleton will be used for both drawing, which is not allowed by the system. So deferring the copy to the work thread will make it generate a new instance for the thread, and the path will not be shared with main thread any more.

Motivation

RUM-9527

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

codecov-commenter commented Jun 12, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.83%. Comparing base (87d7506) to head (6ab4051).
⚠️ Report is 2002 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2723      +/-   ##
===========================================
+ Coverage    69.78%   69.83%   +0.05%     
===========================================
  Files          825      825              
  Lines        30760    30760              
  Branches      5174     5174              
===========================================
+ Hits         21463    21479      +16     
+ Misses        7842     7824      -18     
- Partials      1455     1457       +2     
Files with missing lines Coverage Δ
...ay/internal/recorder/resources/ResourceResolver.kt 77.38% <100.00%> (ø)

... and 37 files with indirect coverage changes

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

@ambushwork
ambushwork marked this pull request as ready for review June 12, 2025 12:33
@ambushwork
ambushwork requested review from a team as code owners June 12, 2025 12:33
@0xnm

0xnm commented Jun 12, 2025

Copy link
Copy Markdown
Member

Won't moving the copy to the worker thread have the following impact, though: by the time we make a copy the content of Drawable will be different from what user saw at the moment we have to record the resource?

@ambushwork

Copy link
Copy Markdown
Member Author

Won't moving the copy to the worker thread have the following impact, though: by the time we make a copy the content of Drawable will be different from what user saw at the moment we have to record the resource?

it is possible that the state of drawable changes during the time, but actually it can still happen even if we do it in the main thread, with this PR the chance becomes higher. The trade-off here is that we can accept the consequence of drawable state change, which can be the replay is not accurate enough, or the image generation fails in our work thread, to avoid crashing the application.

@ambushwork
ambushwork merged commit a83d57c into develop Jun 13, 2025
25 checks passed
@ambushwork
ambushwork deleted the yl/fix-drawable-utils-crash branch June 13, 2025 09:10
@ViliusKraujutis

Copy link
Copy Markdown

Which version will this be released? @ambushwork?

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