From 17c20fc7bbc5c348c94b6d0c85bac5e38f96326b Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 1 Dec 2026 11:16:07 +0100 Subject: [PATCH 1/3] fix(replay): Clear the saved screen name when it becomes null Co-Authored-By: Claude Code --- .../replay/capture/BaseCaptureStrategy.kt | 2 +- .../replay/capture/BufferCaptureStrategyTest.kt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BaseCaptureStrategy.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BaseCaptureStrategy.kt index 6b55cab0bb1..046a83d838e 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BaseCaptureStrategy.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BaseCaptureStrategy.kt @@ -250,7 +250,7 @@ constructor( propertyName: String, crossinline onChange: (propertyName: String?, oldValue: T?, newValue: T?) -> Unit = { _, _, newValue -> - cache?.persistSegmentValues(propertyName, newValue.toString()) + cache?.persistSegmentValues(propertyName, newValue?.toString()) }, ): ReadWriteProperty = object : ReadWriteProperty { diff --git a/sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt b/sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt index a926eb00358..822613c0b89 100644 --- a/sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt +++ b/sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt @@ -2,6 +2,7 @@ package io.sentry.android.replay.capture import android.graphics.Bitmap import android.view.MotionEvent +import com.google.common.truth.Truth.assertThat import io.sentry.DataCategory import io.sentry.IScopes import io.sentry.Scope @@ -16,6 +17,7 @@ import io.sentry.android.replay.GeneratedVideo import io.sentry.android.replay.ReplayCache import io.sentry.android.replay.ReplayCache.Companion.SEGMENT_KEY_ID import io.sentry.android.replay.ReplayCache.Companion.SEGMENT_KEY_REPLAY_ID +import io.sentry.android.replay.ReplayCache.Companion.SEGMENT_KEY_REPLAY_SCREEN_AT_START import io.sentry.android.replay.ReplayCache.Companion.SEGMENT_KEY_REPLAY_TYPE import io.sentry.android.replay.ReplayCache.Companion.SEGMENT_KEY_TIMESTAMP import io.sentry.android.replay.ReplayFrame @@ -250,6 +252,20 @@ class BufferCaptureStrategyTest { verify(fixture.replayCache).rotate(eq(now - fixture.options.sessionReplay.errorReplayDuration)) } + @Test + fun `clears the persisted screen when the last named frame leaves the buffer`() { + val strategy = fixture.getSut() + strategy.start() + whenever(fixture.replayCache.rotate(any())).thenReturn("HomeActivity", null) + + strategy.onScreenshotRecorded {} + assertThat(fixture.persistedSegment[SEGMENT_KEY_REPLAY_SCREEN_AT_START]) + .isEqualTo("HomeActivity") + + strategy.onScreenshotRecorded {} + assertThat(fixture.persistedSegment[SEGMENT_KEY_REPLAY_SCREEN_AT_START]).isNull() + } + @Test fun `onConfigurationChanged creates new segment and updates config`() { val strategy = fixture.getSut() From a1c3a1a6e8e823f9830f8b299195711ddcfd7e33 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 1 Dec 2026 11:16:46 +0100 Subject: [PATCH 2/3] changelog Co-Authored-By: Claude Code --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2eacae4275..0a572b6b968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fixes - Android: A crash long after `Sentry.init` is no longer marked as a startup crash when the device slept in between, because the time since init now counts deep sleep ([#6738](https://github.com/getsentry/sentry-java/pull/6738)) +- Android: Replays recovered after a crash no longer list `"null"` as a screen name when the last named frame leaves the buffer ([#6827](https://github.com/getsentry/sentry-java/pull/6827)) ### Internal From 9e9af263f619b1e10f88fedf7668f466f1053187 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 1 Dec 2026 11:35:59 +0100 Subject: [PATCH 3/3] docs: Use the Session Replay prefix in the changelog Co-Authored-By: Claude Code --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a572b6b968..d64209bed76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ ### Fixes - Android: A crash long after `Sentry.init` is no longer marked as a startup crash when the device slept in between, because the time since init now counts deep sleep ([#6738](https://github.com/getsentry/sentry-java/pull/6738)) -- Android: Replays recovered after a crash no longer list `"null"` as a screen name when the last named frame leaves the buffer ([#6827](https://github.com/getsentry/sentry-java/pull/6827)) +- Session Replay: Replays recovered after a crash no longer list `"null"` as a screen name when the last named frame leaves the buffer ([#6827](https://github.com/getsentry/sentry-java/pull/6827)) ### Internal