You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
✅ 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.
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?
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.
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
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.
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
Drawableit has no problem, exceptMaterialShapeDrawable.MaterialShapeDrawableholds an singleton ofShapeAppearancePathProvideron 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)