-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Android double masking with frame drop #342
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
Merged
Merged
Changes from 78 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
61069a5
add floating button
abelonogov-ld 69799b5
sample of adding floating views
abelonogov-ld 81c369f
consolidate in one view
abelonogov-ld 8b0c650
use Canvas for certain types of windows
abelonogov-ld 6dafcb3
space
abelonogov-ld 04b4c75
Attached dialog sample
abelonogov-ld 55b00a7
no message
abelonogov-ld 8ddba24
fix size bug
abelonogov-ld 008a414
Recycle bitmap early
abelonogov-ld 4d5536b
Fix feedback
abelonogov-ld ce45b42
address feedback
abelonogov-ld 50aee55
Volatile
abelonogov-ld 04c252e
Unit tests
abelonogov-ld 54f08de
create Mask
abelonogov-ld d6fd378
add floating button
abelonogov-ld 59c2f6d
sample of adding floating views
abelonogov-ld 3ff3e81
consolidate in one view
abelonogov-ld 41e2645
use Canvas for certain types of windows
abelonogov-ld ac99967
space
abelonogov-ld 801ae96
Attached dialog sample
abelonogov-ld e618524
Matrix
abelonogov-ld a92e869
Merge branch 'andrey/nonstandard-views' into andrey/delayed-mask2
abelonogov-ld d86bd09
Merge branch 'andrey/do-not-send-duplicate-windows' into andrey/delay…
abelonogov-ld 1ece408
renaming to MaskCollector
abelonogov-ld 3e570b4
add floating button
abelonogov-ld aef3154
sample of adding floating views
abelonogov-ld 12ed36c
consolidate in one view
abelonogov-ld 343690e
use Canvas for certain types of windows
abelonogov-ld a4cf491
space
abelonogov-ld b117d79
Attached dialog sample
abelonogov-ld 55e29da
Filter AndroidComposeView
abelonogov-ld 4c0db23
fix mask warning
abelonogov-ld 0144cef
using root.locationOnScreen
abelonogov-ld 31bb519
address feadback
abelonogov-ld 4daa13f
Merge branch 'andrey/nonstandard-views' into andrey/delayed-mask2
abelonogov-ld 4558bbe
Fix warnings
abelonogov-ld 7cb314b
fix warnings
abelonogov-ld 15825ce
Merge branch 'main' into andrey/mask-collector
abelonogov-ld 89ba6c5
remove ressurectued import
abelonogov-ld 0079a42
address feedback
abelonogov-ld 1180d8b
delete renamed
abelonogov-ld 04d2537
uncomment
abelonogov-ld a632d0e
works for Native views only
abelonogov-ld 7584f01
rotation for XML Views
abelonogov-ld 483930b
transformed coordinates for compose
abelonogov-ld 3052849
reorder calls
abelonogov-ld 50033e8
rebase fix
abelonogov-ld 7a21080
Merge branch 'main' into andrey/transformed-coordinates
abelonogov-ld 934607b
remove import
abelonogov-ld 87c3415
cursor review
abelonogov-ld 16a967c
address feedback
abelonogov-ld 278da36
after before
abelonogov-ld fe4fa07
Merge branch 'andrey/transformed-coordinates' into andrey/double-masking
abelonogov-ld caac714
double painting
abelonogov-ld 164dc72
array based capture works
abelonogov-ld 8b2351a
masking first try
abelonogov-ld b2b1aed
Merge branch 'main' into andrey/double-masking
abelonogov-ld 277ae2e
double masking wip
abelonogov-ld 238b8bd
wip
abelonogov-ld 1703c99
Merge branch 'main' into andrey/double-masking
abelonogov-ld 842a899
delete unused
abelonogov-ld b80c0db
uncomment else
abelonogov-ld 4720fb0
refactor out MaskApplier
abelonogov-ld d8574cc
remove mobile key
abelonogov-ld 71d58cf
Merge branch 'main' into andrey/fix-masking-offset
abelonogov-ld 556365a
Fix color
abelonogov-ld b92e75c
Merge branch 'andrey/fix-masking-offset' of github.com:launchdarkly/o…
abelonogov-ld 45f64f9
Merge branch 'main' into andrey/fix-masking-offset
abelonogov-ld 9e45460
Merge branch 'main' into andrey/fix-masking-offset
abelonogov-ld 8a97643
remove context.root adjustment
abelonogov-ld a053d38
mask stabilizy refactor
abelonogov-ld 854f5f6
Merge branch 'main' into andrey/fix-masking-offset
abelonogov-ld d463fd7
Merge branch 'main' into andrey/stabile-masks
abelonogov-ld feaa22f
no message
abelonogov-ld 96fa993
Merge branch 'main' into andrey/stabile-masks
abelonogov-ld 634faed
Merge branch 'main' into andrey/stabile-masks
abelonogov-ld 5012a15
remove redundant comment
abelonogov-ld 8983a0d
Revert "no message"
abelonogov-ld adc3d2f
address feedback
abelonogov-ld 319c9cc
fix cases null cases
abelonogov-ld 1aa24c9
use pair of masks
abelonogov-ld 60fdfa6
Merge branch 'main' into andrey/double-masking
abelonogov-ld 5038159
use throwable
abelonogov-ld c6cfb6d
address feedback
abelonogov-ld 64f8cd1
address feedback
abelonogov-ld 832e2cf
recycle early
abelonogov-ld 356c484
another recycle
abelonogov-ld 5bff2cd
Apply suggestion from @agrognetti
abelonogov-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
102 changes: 102 additions & 0 deletions
102
...-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/masking/MaskApplier.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package com.launchdarkly.observability.replay.masking | ||
|
|
||
| import android.graphics.Canvas | ||
| import android.graphics.Color | ||
| import android.graphics.Paint | ||
| import android.graphics.Path | ||
| import android.graphics.Rect | ||
| import kotlin.math.abs | ||
|
|
||
| class MaskApplier { | ||
| private val beforeMaskPaint = Paint().apply { | ||
| color = Color.DKGRAY | ||
| style = Paint.Style.FILL | ||
| } | ||
| private val afterMaskPaint = Paint().apply { | ||
| color = Color.GRAY | ||
| style = Paint.Style.FILL | ||
| } | ||
|
|
||
| private val maskIntRect = Rect() | ||
| private val path = Path() | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| fun drawMasks(canvas: Canvas, beforeMasks: List<Mask>?, afterMasks: List<Mask>?) { | ||
| if (afterMasks == null && beforeMasks == null) return | ||
|
|
||
| beforeMasks?.forEach { mask -> | ||
| drawMask(mask, path, canvas, beforeMaskPaint) | ||
| } | ||
| afterMasks?.forEach { mask -> | ||
| drawMask(mask, path, canvas, afterMaskPaint) | ||
| } | ||
| } | ||
|
|
||
| private fun drawMask(mask: Mask, path: Path, canvas: Canvas, paint: Paint) { | ||
| if (mask.points != null) { | ||
| val pts = mask.points | ||
|
|
||
| path.reset() | ||
| path.moveTo(pts[0], pts[1]) | ||
| path.lineTo(pts[2], pts[3]) | ||
| path.lineTo(pts[4], pts[5]) | ||
| path.lineTo(pts[6], pts[7]) | ||
abelonogov-ld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| path.close() | ||
|
|
||
| canvas.drawPath(path, paint) | ||
| } else { | ||
| maskIntRect.left = mask.rect.left.toInt() | ||
| maskIntRect.top = mask.rect.top.toInt() | ||
| maskIntRect.right = mask.rect.right.toInt() | ||
| maskIntRect.bottom = mask.rect.bottom.toInt() | ||
| canvas.drawRect(maskIntRect, paint) | ||
| } | ||
| } | ||
|
|
||
| fun filteredBeforeMasksMap( | ||
| beforeMasksMap: List<List<Mask>?>, | ||
| afterMasksMap: List<List<Mask>?> | ||
| ): MutableList<List<Mask>?>? { | ||
| if (afterMasksMap.count() == 0) { | ||
| return null | ||
| } | ||
|
|
||
| val result: MutableList<List<Mask>?> = MutableList(beforeMasksMap.size) { null } | ||
| for (i in beforeMasksMap.indices) { | ||
| val before = beforeMasksMap[i] ?: continue | ||
| val after = afterMasksMap[i] ?: return null | ||
| val merged = filteredBeforeMasks(before, after) ?: return null | ||
| result[i] = merged | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return result | ||
| } | ||
|
|
||
| // Check if masks are stable and returns null if not | ||
| private fun filteredBeforeMasks( | ||
| beforeMasks: List<Mask>, | ||
| afterMasks: List<Mask> | ||
| ): List<Mask>? { | ||
| if (afterMasks.count() != beforeMasks.count()) { | ||
| return null | ||
| } | ||
|
|
||
| if (afterMasks.count() == 0) { | ||
| return listOf() | ||
| } | ||
|
|
||
| val stabilityTolerance = 40f | ||
| val resultMasks = mutableListOf<Mask>() | ||
| for ((before, after) in beforeMasks.zip(afterMasks)) { | ||
| if (before.viewId != after.viewId) { | ||
| return null | ||
| } | ||
| val diff = abs(after.rect.top - before.rect.top) | ||
| if (diff > stabilityTolerance) { | ||
| return null | ||
| } | ||
| resultMasks += before | ||
| } | ||
|
|
||
| return resultMasks | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.