Skip to content

Commit b7489d7

Browse files
authored
[SR] Mask web and video views (#3775)
1 parent 724865d commit b7489d7

5 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- If you're using code obfuscation, adjust your proguard-rules accordingly, so your custom view class name is not minified
1616
- Session Replay: Support Jetpack Compose masking ([#3739](https://github.com/getsentry/sentry-java/pull/3739))
1717
- To selectively mask/unmask @Composables, use `Modifier.sentryReplayMask()` and `Modifier.sentryReplayUnmask()` modifiers
18+
- Session Replay: Mask `WebView`, `VideoView` and `androidx.media3.ui.PlayerView` by default ([#3775](https://github.com/getsentry/sentry-java/pull/3775))
1819

1920
### Fixes
2021

sentry-android-replay/proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
# Rules to detect a compose view to parse its hierarchy
1919
-dontwarn androidx.compose.ui.platform.AndroidComposeView
2020
-keepnames class androidx.compose.ui.platform.AndroidComposeView
21+
# Rules to detect a media player view to later mask it
22+
-dontwarn androidx.media3.ui.PlayerView
23+
-keepnames class androidx.media3.ui.PlayerView

sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ internal class SimpleVideoEncoder(
136136
)
137137
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate)
138138
format.setFloat(MediaFormat.KEY_FRAME_RATE, muxerConfig.frameRate.toFloat())
139-
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, -1) // use -1 to force always non-key frames, meaning only partial updates to save the video size
139+
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 6) // use 6 to force non-key frames, meaning only partial updates to save the video size. Every 6th second is a key frame, which is useful for buffer mode
140140

141141
format
142142
}

sentry/api/sentry.api

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,8 +2709,13 @@ public final class io/sentry/SentryReplayEvent$ReplayType$Deserializer : io/sent
27092709
}
27102710

27112711
public final class io/sentry/SentryReplayOptions {
2712+
public static final field ANDROIDX_MEDIA_VIEW_CLASS_NAME Ljava/lang/String;
2713+
public static final field EXOPLAYER_CLASS_NAME Ljava/lang/String;
2714+
public static final field EXOPLAYER_STYLED_CLASS_NAME Ljava/lang/String;
27122715
public static final field IMAGE_VIEW_CLASS_NAME Ljava/lang/String;
27132716
public static final field TEXT_VIEW_CLASS_NAME Ljava/lang/String;
2717+
public static final field VIDEO_VIEW_CLASS_NAME Ljava/lang/String;
2718+
public static final field WEB_VIEW_CLASS_NAME Ljava/lang/String;
27142719
public fun <init> ()V
27152720
public fun <init> (Ljava/lang/Double;Ljava/lang/Double;)V
27162721
public fun addMaskViewClass (Ljava/lang/String;)V

sentry/src/main/java/io/sentry/SentryReplayOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ public final class SentryReplayOptions {
1111

1212
public static final String TEXT_VIEW_CLASS_NAME = "android.widget.TextView";
1313
public static final String IMAGE_VIEW_CLASS_NAME = "android.widget.ImageView";
14+
public static final String WEB_VIEW_CLASS_NAME = "android.webkit.WebView";
15+
public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView";
16+
public static final String ANDROIDX_MEDIA_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView";
17+
public static final String EXOPLAYER_CLASS_NAME = "com.google.android.exoplayer2.ui.PlayerView";
18+
public static final String EXOPLAYER_STYLED_CLASS_NAME =
19+
"com.google.android.exoplayer2.ui.StyledPlayerView";
1420

1521
public enum SentryReplayQuality {
1622
/** Video Scale: 80% Bit Rate: 50.000 */
@@ -99,6 +105,11 @@ public enum SentryReplayQuality {
99105
public SentryReplayOptions() {
100106
setMaskAllText(true);
101107
setMaskAllImages(true);
108+
maskViewClasses.add(WEB_VIEW_CLASS_NAME);
109+
maskViewClasses.add(VIDEO_VIEW_CLASS_NAME);
110+
maskViewClasses.add(ANDROIDX_MEDIA_VIEW_CLASS_NAME);
111+
maskViewClasses.add(EXOPLAYER_CLASS_NAME);
112+
maskViewClasses.add(EXOPLAYER_STYLED_CLASS_NAME);
102113
}
103114

104115
public SentryReplayOptions(

0 commit comments

Comments
 (0)