diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cb73a5552..c9aeae67a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Use logger from options for JVM profiler ([#4771](https://github.com/getsentry/sentry-java/pull/4771)) - Session Replay: Avoid deadlock when pausing replay if no connection ([#4788](https://github.com/getsentry/sentry-java/pull/4788)) +- Session Replay: Fix capturing roots with no windows ([#4805](https://github.com/getsentry/sentry-java/pull/4805)) +- Session Replay: Fix `java.lang.IllegalArgumentException: width and height must be > 0` ([#4805](https://github.com/getsentry/sentry-java/pull/4805)) ### Miscellaneous diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/ScreenshotRecorder.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/ScreenshotRecorder.kt index 2d866e6a6d..3bc995fad2 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/ScreenshotRecorder.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/ScreenshotRecorder.kt @@ -289,7 +289,7 @@ public data class ScreenshotRecorderConfig( private fun Int.adjustToBlockSize(): Int { val remainder = this % 16 return if (remainder <= 8) { - this - remainder + maxOf(16, this - remainder) } else { this + (16 - remainder) } diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/WindowRecorder.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/WindowRecorder.kt index 5731c4e4f5..eec316e5c3 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/WindowRecorder.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/WindowRecorder.kt @@ -110,6 +110,11 @@ internal class WindowRecorder( override fun onRootViewsChanged(root: View, added: Boolean) { rootViewsLock.acquire().use { if (added) { + if (root.phoneWindow == null) { + options.logger.log(WARNING, "Root view does not have a phone window, skipping.") + return + } + rootViews.add(WeakReference(root)) capturer?.recorder?.bind(root) determineWindowSize(root)