-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUM-1012 Fix RippleDrawables #1600
Conversation
7f88d90
to
b7e6b45
Compare
@@ -129,6 +135,17 @@ internal class ImageWireframeHelper( | |||
return result | |||
} | |||
|
|||
private fun resolveDrawableProperties(view: View, drawable: Drawable?): DrawableProperties { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice ;)
@@ -180,7 +180,7 @@ abstract class BaseWireframeMapper<T : View, S : MobileSegment.Wireframe>( | |||
y = bounds.y, | |||
width, | |||
height, | |||
view.background, | |||
view.background?.constantState?.newDrawable(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you create a new drawable here ? isn't this costly for each view ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preferably we wouldn't need to do this, however if the drawable is not moved to a new instance before we create the bitmap, then modifying the drawable to draw the bitmap modifies the view in the app itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I see so you need to take a copy ...hmmm...I wonder how expensive this is for each view. Sorry for asking but why do you need to modify the Drawable to create the bitmap from it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to set the bounds before I can draw to the canvas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that if profiling it shows decent number we can go with this like that. @0xnm, @xgouchet waiting for your thoughts on this one. I searched for a way to go around it, but apparently there's not, the only other way is to setBounds
when before drawing
and try to put the drawable back into its previous state after. Not sure how reliable this is and honestly I think I would rather go with the copy.
Codecov Report
@@ Coverage Diff @@
## develop #1600 +/- ##
===========================================
- Coverage 83.67% 83.55% -0.11%
===========================================
Files 451 452 +1
Lines 15563 15625 +62
Branches 2318 2321 +3
===========================================
+ Hits 13021 13055 +34
- Misses 1928 1948 +20
- Partials 614 622 +8
|
...in/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/ImageWireframeHelper.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the need to have the ripple drawables converted to base64?
By definition a RippleDrawable is an animated drawable used to show feedback when tapping on interactive views (e.g. buttons).
Saving those as bitmaps means we'll either have to save the whole animation because everytime we draw them the animation state will be different, or it's going to only store a single ripple state which will look weird in the replay.
Either way, should'n we instead save them as a solid background for now, and wait for a better solution to record/replay the ripple effect?
...in/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/ImageWireframeHelper.kt
Outdated
Show resolved
Hide resolved
...rc/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/wrappers/BitmapWrapper.kt
Show resolved
Hide resolved
e8430b3
to
2bc4cfd
Compare
...in/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/ImageWireframeHelper.kt
Show resolved
Hide resolved
...c/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/Base64Serializer.kt
Outdated
Show resolved
Hide resolved
...in/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/ImageWireframeHelper.kt
Show resolved
Hide resolved
...rc/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/wrappers/BitmapWrapper.kt
Show resolved
Hide resolved
0dac84c
to
564979a
Compare
...c/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/base64/Base64Serializer.kt
Show resolved
Hide resolved
...rc/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/wrappers/CanvasWrapper.kt
Show resolved
Hide resolved
...play/src/main/kotlin/com/datadog/android/sessionreplay/internal/recorder/LayerDrawableExt.kt
Outdated
Show resolved
Hide resolved
e6aa860
to
3b0b069
Compare
3b0b069
to
6e89a6d
Compare
6e89a6d
to
ffb98cd
Compare
What does this PR do?
Fixes RippleDrawables not converting correctly to base64 (caused by it's dimensions being -1, and RippleDrawable not being the actual drawable from which we can create a bitmap). In this fix, the InsetDrawable is extracted from the RippleDrawable, and the GradientDrawable is extracted from that - we then use the dimensions of the view as the dimensions of the drawable (this doesn't affect the created bitmap so much, since the bitmap is rescaled to 10kbs or less before caching).
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)