From d6ee508133a5ae0a1cdcea18d305c1928c4fb6e8 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 10:17:27 +0200 Subject: [PATCH 1/7] Revert key frame interval to 10 --- .../java/io/sentry/android/replay/video/SimpleVideoEncoder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt index baf521a2e67..6c0845c3901 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt @@ -136,7 +136,7 @@ internal class SimpleVideoEncoder( ) format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate) format.setFloat(MediaFormat.KEY_FRAME_RATE, muxerConfig.frameRate.toFloat()) - 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 + format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10) // use 10 to force non-key frames, meaning only partial updates to save the video size. Every 10th second is a key frame, which is useful for buffer mode format } From 6942db193d19084362e446b8795cb79df76428ab Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 11:28:30 +0200 Subject: [PATCH 2/7] Add more masked classes by default --- sentry/src/main/java/io/sentry/SentryReplayOptions.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sentry/src/main/java/io/sentry/SentryReplayOptions.java b/sentry/src/main/java/io/sentry/SentryReplayOptions.java index 35e6aba718a..4a1bb2f996d 100644 --- a/sentry/src/main/java/io/sentry/SentryReplayOptions.java +++ b/sentry/src/main/java/io/sentry/SentryReplayOptions.java @@ -11,6 +11,9 @@ public final class SentryReplayOptions { public static final String TEXT_VIEW_CLASS_NAME = "android.widget.TextView"; public static final String IMAGE_VIEW_CLASS_NAME = "android.widget.ImageView"; + public static final String WEB_VIEW_CLASS_NAME = "android.webkit.WebView"; + public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView"; + public static final String EXOPLAYER_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView"; public enum SentryReplayQuality { /** Video Scale: 80% Bit Rate: 50.000 */ @@ -99,6 +102,9 @@ public enum SentryReplayQuality { public SentryReplayOptions() { setMaskAllText(true); setMaskAllImages(true); + maskViewClasses.add(WEB_VIEW_CLASS_NAME); + maskViewClasses.add(VIDEO_VIEW_CLASS_NAME); + maskViewClasses.add(EXOPLAYER_VIEW_CLASS_NAME); } public SentryReplayOptions( From f7ade2dfeb6f04ea6080adefaebf9594dd3fc8f8 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 11:34:30 +0200 Subject: [PATCH 3/7] Proguard rules --- sentry-android-replay/proguard-rules.pro | 3 +++ sentry/src/main/java/io/sentry/SentryReplayOptions.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sentry-android-replay/proguard-rules.pro b/sentry-android-replay/proguard-rules.pro index c537ff73990..c975793b823 100644 --- a/sentry-android-replay/proguard-rules.pro +++ b/sentry-android-replay/proguard-rules.pro @@ -18,3 +18,6 @@ # Rules to detect a compose view to parse its hierarchy -dontwarn androidx.compose.ui.platform.AndroidComposeView -keepnames class androidx.compose.ui.platform.AndroidComposeView +# Rules to detect a media player view to later mask it +-dontwarn androidx.media3.ui.PlayerView +-keepnames class androidx.media3.ui.PlayerView diff --git a/sentry/src/main/java/io/sentry/SentryReplayOptions.java b/sentry/src/main/java/io/sentry/SentryReplayOptions.java index 4a1bb2f996d..9f5436d1ffb 100644 --- a/sentry/src/main/java/io/sentry/SentryReplayOptions.java +++ b/sentry/src/main/java/io/sentry/SentryReplayOptions.java @@ -13,7 +13,7 @@ public final class SentryReplayOptions { public static final String IMAGE_VIEW_CLASS_NAME = "android.widget.ImageView"; public static final String WEB_VIEW_CLASS_NAME = "android.webkit.WebView"; public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView"; - public static final String EXOPLAYER_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView"; + public static final String ANDROIDX_MEDIA_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView"; public enum SentryReplayQuality { /** Video Scale: 80% Bit Rate: 50.000 */ @@ -104,7 +104,7 @@ public SentryReplayOptions() { setMaskAllImages(true); maskViewClasses.add(WEB_VIEW_CLASS_NAME); maskViewClasses.add(VIDEO_VIEW_CLASS_NAME); - maskViewClasses.add(EXOPLAYER_VIEW_CLASS_NAME); + maskViewClasses.add(ANDROIDX_MEDIA_VIEW_CLASS_NAME); } public SentryReplayOptions( From 7116036bbf350e962b2f4ae7eef3b7eca34cb2d5 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 12:52:40 +0200 Subject: [PATCH 4/7] Changelog --- CHANGELOG.md | 1 + sentry/api/sentry.api | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 572e71fb3a6..c1a9456edd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - If you're using code obfuscation, adjust your proguard-rules accordingly, so your custom view class name is not minified - Session Replay: Support Jetpack Compose masking ([#3739](https://github.com/getsentry/sentry-java/pull/3739)) - To selectively mask/unmask @Composables, use `Modifier.sentryReplayMask()` and `Modifier.sentryReplayUnmask()` modifiers +- Session Replay: Mask `WebView`, `VideoView` and `androidx.media3.ui.PlayerView` by default ([#3775](https://github.com/getsentry/sentry-java/pull/3775)) ### Fixes diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index da036d225e2..facfabe4716 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -2709,8 +2709,11 @@ public final class io/sentry/SentryReplayEvent$ReplayType$Deserializer : io/sent } public final class io/sentry/SentryReplayOptions { + public static final field ANDROIDX_MEDIA_VIEW_CLASS_NAME Ljava/lang/String; public static final field IMAGE_VIEW_CLASS_NAME Ljava/lang/String; public static final field TEXT_VIEW_CLASS_NAME Ljava/lang/String; + public static final field VIDEO_VIEW_CLASS_NAME Ljava/lang/String; + public static final field WEB_VIEW_CLASS_NAME Ljava/lang/String; public fun ()V public fun (Ljava/lang/Double;Ljava/lang/Double;)V public fun addMaskViewClass (Ljava/lang/String;)V From 0df00901b7b46eb960fe145fd81be29831b0762a Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 19:58:37 +0200 Subject: [PATCH 5/7] Change 10 to 6 --- .../java/io/sentry/android/replay/video/SimpleVideoEncoder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt index 6c0845c3901..211decc098d 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/video/SimpleVideoEncoder.kt @@ -136,7 +136,7 @@ internal class SimpleVideoEncoder( ) format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate) format.setFloat(MediaFormat.KEY_FRAME_RATE, muxerConfig.frameRate.toFloat()) - format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10) // use 10 to force non-key frames, meaning only partial updates to save the video size. Every 10th second is a key frame, which is useful for buffer mode + 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 format } From dcb6dcbaed82771b4184b074890a7828136fb815 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 20:09:38 +0200 Subject: [PATCH 6/7] Add exoplayer classes --- sentry/api/sentry.api | 2 ++ sentry/src/main/java/io/sentry/SentryReplayOptions.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index facfabe4716..bfd644c64fe 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -2710,6 +2710,8 @@ public final class io/sentry/SentryReplayEvent$ReplayType$Deserializer : io/sent public final class io/sentry/SentryReplayOptions { public static final field ANDROIDX_MEDIA_VIEW_CLASS_NAME Ljava/lang/String; + public static final field EXOPLAYER_CLASS_NAME Ljava/lang/String; + public static final field EXOPLAYER_STYLED_CLASS_NAME Ljava/lang/String; public static final field IMAGE_VIEW_CLASS_NAME Ljava/lang/String; public static final field TEXT_VIEW_CLASS_NAME Ljava/lang/String; public static final field VIDEO_VIEW_CLASS_NAME Ljava/lang/String; diff --git a/sentry/src/main/java/io/sentry/SentryReplayOptions.java b/sentry/src/main/java/io/sentry/SentryReplayOptions.java index 9f5436d1ffb..629a46a43ef 100644 --- a/sentry/src/main/java/io/sentry/SentryReplayOptions.java +++ b/sentry/src/main/java/io/sentry/SentryReplayOptions.java @@ -14,6 +14,8 @@ public final class SentryReplayOptions { public static final String WEB_VIEW_CLASS_NAME = "android.webkit.WebView"; public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView"; public static final String ANDROIDX_MEDIA_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView"; + public static final String EXOPLAYER_CLASS_NAME = "com.google.android.exoplayer2.ui.PlayerView"; + public static final String EXOPLAYER_STYLED_CLASS_NAME = "com.google.android.exoplayer2.ui.StyledPlayerView"; public enum SentryReplayQuality { /** Video Scale: 80% Bit Rate: 50.000 */ @@ -105,6 +107,8 @@ public SentryReplayOptions() { maskViewClasses.add(WEB_VIEW_CLASS_NAME); maskViewClasses.add(VIDEO_VIEW_CLASS_NAME); maskViewClasses.add(ANDROIDX_MEDIA_VIEW_CLASS_NAME); + maskViewClasses.add(EXOPLAYER_CLASS_NAME); + maskViewClasses.add(EXOPLAYER_STYLED_CLASS_NAME); } public SentryReplayOptions( From d4b551f1e13971f7e0ae4546157c02fa955a3a6a Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 8 Oct 2024 20:18:47 +0200 Subject: [PATCH 7/7] formatting --- sentry/src/main/java/io/sentry/SentryReplayOptions.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry/src/main/java/io/sentry/SentryReplayOptions.java b/sentry/src/main/java/io/sentry/SentryReplayOptions.java index 629a46a43ef..e2931371c7c 100644 --- a/sentry/src/main/java/io/sentry/SentryReplayOptions.java +++ b/sentry/src/main/java/io/sentry/SentryReplayOptions.java @@ -15,7 +15,8 @@ public final class SentryReplayOptions { public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView"; public static final String ANDROIDX_MEDIA_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView"; public static final String EXOPLAYER_CLASS_NAME = "com.google.android.exoplayer2.ui.PlayerView"; - public static final String EXOPLAYER_STYLED_CLASS_NAME = "com.google.android.exoplayer2.ui.StyledPlayerView"; + public static final String EXOPLAYER_STYLED_CLASS_NAME = + "com.google.android.exoplayer2.ui.StyledPlayerView"; public enum SentryReplayQuality { /** Video Scale: 80% Bit Rate: 50.000 */