getsentry / getsentry/sentry-java

Improve masking for PixelCopyStrategy unstable captures

Open
#5,493 2 comments 1 reaction 0 assignees View on GitHub
Android Improvement Replays
Dominant language
Kotlin
Stars
1.4k
Forks
478
Avg merge
2d 23h
Merged PRs (30d)
67

Description

### Description

from @0xadam-brown

> Not sure if we want the extra security, but we could also consider:
>
> increasing the mask size when recording unstable captures, or
> covering the view's entire range of possible positions during the unstable window, ie, the union of where it was (in the pixels, time T) and where the hierarchy thinks it is (T+delta).

I put this into codex, and this is its analysis:
```
Option 1, "increase mask size for unstable captures," is the only reasonably small one. Mechanically it's not huge: add an unstableMaskPaddingPx or similar parameter to
MaskRenderer.renderMasks(...), inflate mask rects when changedDuringCapture == true, clamp them, and update debug overlay/tests. The tricky part is picking a padding that actually helps
without making replay look over-masked. A fixed 8-16dp helps slow movement, but won't cover fast animations, scrolling, shared-element transitions, keyboard movement, etc.

Option 2, "union where it was and where hierarchy thinks it is," is a much bigger lift. We don't currently have a hierarchy snapshot at PixelCopy's exact copy time. To approximate it,
we'd need to capture hierarchy before PixelCopy and after PixelCopy, then match nodes across snapshots. That gets messy for Compose nodes, text line masks, list recycling, visibility
changes, and any node without stable identity. It also adds more main-thread traversal work, which works against the ANR/perf goal.
```

so this probably needs some refinement/further brainstorming

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.