Skip to content

RUM-936: Serialize TextViews/Buttons to base64#1592

Merged
jonathanmos merged 1 commit into
feature/base64-jmoskovichfrom
jmoskovich/replay-1726/base64-textviews
Sep 4, 2023
Merged

RUM-936: Serialize TextViews/Buttons to base64#1592
jonathanmos merged 1 commit into
feature/base64-jmoskovichfrom
jmoskovich/replay-1726/base64-textviews

Conversation

@jonathanmos

Copy link
Copy Markdown
Member

What does this PR do?

Implement serialization of TextViews and Buttons to base64.

Motivation

Continuation of base64 support for different views.

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)

@jonathanmos
jonathanmos changed the base branch from develop to feature/base64-jmoskovich August 30, 2023 11:49
@jonathanmos
jonathanmos force-pushed the jmoskovich/replay-1726/base64-textviews branch 2 times, most recently from 6acc1fc to 00b44c6 Compare August 30, 2023 12:16
@codecov-commenter

codecov-commenter commented Aug 30, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1592 (c3bc12b) into feature/base64-jmoskovich (d4c8e5b) will increase coverage by 0.06%.
The diff coverage is 96.60%.

@@                      Coverage Diff                      @@
##           feature/base64-jmoskovich    #1592      +/-   ##
=============================================================
+ Coverage                      83.44%   83.50%   +0.06%     
=============================================================
  Files                            446      446              
  Lines                          15181    15305     +124     
  Branches                        2288     2299      +11     
=============================================================
+ Hits                           12667    12779     +112     
- Misses                          1912     1928      +16     
+ Partials                         602      598       -4     
Files Changed Coverage Δ
...ionreplay/internal/recorder/mapper/ButtonMapper.kt 87.50% <80.00%> (-12.50%) ⬇️
...nreplay/internal/recorder/mapper/TextViewMapper.kt 92.16% <94.29%> (+1.37%) ⬆️
...y/internal/recorder/base64/ImageWireframeHelper.kt 97.47% <96.00%> (+6.56%) ⬆️
...adog/android/sessionreplay/SessionReplayPrivacy.kt 100.00% <100.00%> (ø)
...ssionreplay/internal/recorder/ViewUtilsInternal.kt 100.00% <100.00%> (ø)
...play/internal/recorder/mapper/ImageButtonMapper.kt 93.33% <100.00%> (ø)
...nternal/recorder/mapper/MaskInputTextViewMapper.kt 83.33% <100.00%> (+33.33%) ⬆️
...lay/internal/recorder/mapper/MaskTextViewMapper.kt 100.00% <100.00%> (ø)

... and 16 files with indirect coverage changes

@jonathanmos
jonathanmos force-pushed the jmoskovich/replay-1726/base64-textviews branch 5 times, most recently from 09325c9 to 3307416 Compare August 31, 2023 12:21
@jonathanmos
jonathanmos marked this pull request as ready for review August 31, 2023 12:44
@jonathanmos
jonathanmos requested a review from a team as a code owner August 31, 2023 12:44

@0xnm 0xnm 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 feature! I added few questions/suggestions


return compoundDrawableLocationMap
}
private fun getCompoundDrawableStartCoords(

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.

what are the start/top/end/bottom coordinates of the compound drawable? what do they describe?

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.

It describes the absolute positions of the drawables surrounding the TextView

return result
}

private fun createCompoundDrawableLocationMap(

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.

overall I think this logic needs to be simplified here, right now is quite hard to read and as @0xnm mentioned I am not sure you need all this logic

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.

In the end the problem that you are trying to solve is to get the bounds of a drawable depending on its parent (view) global bounds + padding + position (left, right, top, bottom) . I think you can find a cleaner logic to achieve this.

@jonathanmos jonathanmos Sep 4, 2023

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.

I've simplified and moved the bounds logic into ViewUtilsInternal

@jonathanmos
jonathanmos force-pushed the jmoskovich/replay-1726/base64-textviews branch 2 times, most recently from abb64fc to f117c2d Compare September 4, 2023 00:12
mariusc83
mariusc83 previously approved these changes Sep 4, 2023

@mariusc83 mariusc83 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 work, LGTM !!


private companion object {
private const val DRAWABLE_CHILD_NAME = "drawable"
@Suppress("NestedBlockDepth")

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.

much much better this way, tks !!

val (shapeStyle, border) = view.background?.resolveShapeStyleAndBorder(view.alpha)
?: (null to null)

resolveTextElements(

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.

I like this and is quite scalable

@0xnm 0xnm 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.

looks good! I left some final suggestions.

@Suppress("ThreadSafety") // TODO REPLAY-1861 caller thread of .map is unknown?
createImageWireframe(
view = view,
index = ++currentIndex,

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.

I would also suggest to convert index to enum in this method instead of doing it inside createImageWireframe, this has several advantages:

  • we don't use index in the createImageWireframe, it removes confusion because when inside createImageWireframe it is not clear what is the index.
  • createImageWireframe signature is cleaner, it will get an enum.
  • it will remove the need for CompoundDrawablePositions to have position property, because you can create it right in the beginning of the forEachIndexed lambda in the following way:
val drawablePosition = when(index) {
   0 -> ...
   1 -> ...
   ...
}

since it will be close to the comment describing compoundDrawables property, it will be clear what is the index.

@jonathanmos jonathanmos Sep 4, 2023

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.

I understand the confusion here - this is a different index. The index for compoundDrawable represents the left, top, right, bottom drawable, however the index for createImageWireframe represents the index of the wireframe in the stack of wireframes. Since we are creating potentially multiple imagewireframes off the same view we need a way to generate unique ids for each wireframe to avoid collisions - this can be seen in line39 of imageWireframeHelper where the index is appended to the resolveChildUniqueIdentifier call.

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.

Then still maybe it is better to remove this confusion, because here https://github.com/DataDog/dd-sdk-android/pull/1592/files#diff-7870c4af39004135266ff0b27eb0e6ee96774f0443572f43f1225b716dc9a0d3R80 it is still 0 to left, etc. So we can create enum in the current method, and let then index to be used in createImageWireframe only for ID generation.

@jonathanmos
jonathanmos requested a review from 0xnm September 4, 2023 12:03
0xnm
0xnm previously approved these changes Sep 4, 2023

@0xnm 0xnm 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.

lgtm! I added few suggestions, but they are not blocking.

@jonathanmos
jonathanmos force-pushed the jmoskovich/replay-1726/base64-textviews branch from 63dc7b6 to c3bc12b Compare September 4, 2023 13:04
@jonathanmos
jonathanmos force-pushed the jmoskovich/replay-1726/base64-textviews branch from c3bc12b to 7ad210b Compare September 4, 2023 13:48
@jonathanmos
jonathanmos merged commit 2752b3f into feature/base64-jmoskovich Sep 4, 2023
@jonathanmos
jonathanmos deleted the jmoskovich/replay-1726/base64-textviews branch September 4, 2023 14:19
@xgouchet xgouchet added this to the 2.2.0 milestone Dec 13, 2023
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