Skip to content

Commit ac2561c

Browse files
committed
fix(replay): Inconsistent segment_id (#4471)
1 parent 940b89a commit ac2561c

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Fix unregister `SystemEventsBroadcastReceiver` when entering background ([#4338](https://github.com/getsentry/sentry-java/pull/4338))
1111
- This should reduce ANRs seen with this class in the stack trace for Android 14 and above
1212
- Pre-load modules on a background thread upon SDK init ([#4348](https://github.com/getsentry/sentry-java/pull/4348))
13+
- Session Replay: Fix inconsistent `segment_id` ([#4471](https://github.com/getsentry/sentry-java/pull/4471))
1314

1415
## 7.22.5
1516

sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BaseCaptureStrategy.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ internal abstract class BaseCaptureStrategy(
109109

110110
override fun stop() {
111111
cache?.close()
112-
currentSegment = -1
113112
replayStartTimestamp.set(0)
114113
segmentTimestamp = null
115114
currentReplayId = SentryId.EMPTY_ID

sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BufferCaptureStrategy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ internal class BufferCaptureStrategy(
5757
val replayCacheDir = cache?.replayCacheDir
5858
replayExecutor.submitSafely(options, "$TAG.stop") {
5959
FileUtils.deleteRecursively(replayCacheDir)
60+
currentSegment = -1
6061
}
6162
super.stop()
6263
}
@@ -197,15 +198,14 @@ internal class BufferCaptureStrategy(
197198
} else {
198199
DateUtils.getDateTime(now - errorReplayDuration)
199200
}
200-
val segmentId = currentSegment
201201
val duration = now - currentSegmentTimestamp.time
202202
val replayId = currentReplayId
203203
val height = this.recorderConfig.recordingHeight
204204
val width = this.recorderConfig.recordingWidth
205205

206206
replayExecutor.submitSafely(options, "$TAG.$taskName") {
207207
val segment =
208-
createSegmentInternal(duration, currentSegmentTimestamp, replayId, segmentId, height, width)
208+
createSegmentInternal(duration, currentSegmentTimestamp, replayId, currentSegment, height, width)
209209
onSegmentCreated(segment)
210210
}
211211
}

sentry-android-replay/src/main/java/io/sentry/android/replay/capture/SessionCaptureStrategy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ internal class SessionCaptureStrategy(
6060
if (segment is ReplaySegment.Created) {
6161
segment.capture(hub)
6262
}
63+
currentSegment = -1
6364
FileUtils.deleteRecursively(replayCacheDir)
6465
}
6566
hub?.configureScope { it.replayId = SentryId.EMPTY_ID }
@@ -137,14 +138,13 @@ internal class SessionCaptureStrategy(
137138
private fun createCurrentSegment(taskName: String, onSegmentCreated: (ReplaySegment) -> Unit) {
138139
val now = dateProvider.currentTimeMillis
139140
val currentSegmentTimestamp = segmentTimestamp ?: return
140-
val segmentId = currentSegment
141141
val duration = now - currentSegmentTimestamp.time
142142
val replayId = currentReplayId
143143
val height = recorderConfig.recordingHeight
144144
val width = recorderConfig.recordingWidth
145145
replayExecutor.submitSafely(options, "$TAG.$taskName") {
146146
val segment =
147-
createSegmentInternal(duration, currentSegmentTimestamp, replayId, segmentId, height, width)
147+
createSegmentInternal(duration, currentSegmentTimestamp, replayId, currentSegment, height, width)
148148
onSegmentCreated(segment)
149149
}
150150
}

0 commit comments

Comments
 (0)