Repository navigation
fix(replay): Keep the replay timeline anchored across wall-clock jumps - #6542
Open
runningcode wants to merge 9 commits into
Open
runningcode wants to merge 9 commits into
runningcode wants to merge 9 commits into
Conversation
📲 Install BuildsAndroid
|
runningcode
force-pushed
the
no/java-829-replay-anchored-clock
branch
from
November 16, 2026 13:57
ee1e8b3 to
76e20a4
Compare
runningcode
marked this pull request as ready for review
November 16, 2026 13:59
runningcode
requested review from
0xadam-brown and
markushi
and removed request for
a team
November 16, 2026 13:59
Session Replay stamped frames, cut segments, trimmed the buffer and stamped gestures from repeated wall-clock reads. A device clock change mid-recording then dropped frames (backward) or sent one frozen 5s segment per frame until the segment start caught up (forward); buffer mode got negative durations or rotated out the whole buffer. Each recording now stamps on an AnchoredClock (ReplayClock). Every captured frame compares it with the wall clock; past a 1s tolerance the current segment closes where the old timeline ended and the next one starts on a new anchor, so the jump shows once as a gap or an overlap and breadcrumbs, errors and spans stay aligned with the video. Touch events stamped on the old timeline go into the closing segment. A forward jump longer than sessionDuration stops a session recording the way the cap does. Buffered segments age on the timeline they were stamped on. Without a jump, every serialized value matches the wall clock as before. Fixes GH-6522 Fixes JAVA-829 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent requests Buffer mode now drops what it recorded before a forward wall-clock jump longer than sessionDuration: the pre-jump frames, touch events and already buffered segments. It keeps recording on the new timeline, so an error soon after no longer sends one replay spanning hours or years. Session mode already stops at the same jump. Segment requests (pause, flush, stop, configuration change, error flush) read their times when made, so a busy executor doesn't stretch the segment. If a frame moved the recording onto a new timeline in between, those times and the frames the task finds were on different timelines: a backward jump could produce a frozen segment minutes long, and a buffer flush right after a forward jump could stretch one frame over the whole jump. The strategies now track the timeline their queued work is on, and a request's task reads its times again on that timeline when it differs from the one the request read. Without a jump nothing is re-read, so every value stays what it was. resume() no longer re-anchors the clock. Otherwise every request until its queued task runs would look like it raced a jump. A jump while paused is followed by the first frame after resume, like any other. Refs GH-6522 Refs JAVA-829 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The function references and generateSequence pulled in kotlin.jvm.internal.FunctionReferenceImpl and kotlin.sequences.SequencesKt, which R8 reports as missing in the SDK size app. A lambda and a plain loop keep replay's Kotlin stdlib footprint as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… jump A frame that followed a jump drained every queued touch event into the segment closing the old timeline at stamp time. A segment task already queued before it, such as a 5s boundary or a pause, then built its recording without its touches, and the closing segment dropped them because they were stamped before its start. Each timeline now has its own touch-event queue. The jump starts a new one for touches, and segments built on the replay executor keep using the old one until the jump's task moves the executor onto the new timeline. Refs JAVA-829 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runningcode
force-pushed
the
no/java-829-replay-anchored-clock
branch
from
November 17, 2026 10:05
019fbd3 to
5259890
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eb8b9cd. Configure here.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

📜 Description
Session Replay stamped frames, segment boundaries, the buffer window and touches with the wall clock, so changing the device clock mid-recording broke the video. A backward change dropped frames until the clock caught up, a forward change cut a frozen 5s segment on every frame, and buffer mode could produce negative durations or rotate out the whole buffer.
Each recording now stamps on one
AnchoredClock, held by a new internalReplayClock. Every captured frame compares it with the wall clock. When the two differ by more than 1s, the current segment closes where the old timeline ended and the next one starts on a new anchor at the wall clock. Breadcrumbs and errors, which are still stamped from the wall clock, stay aligned with the video, and the jump shows once in the replay as a gap or an overlap.For example, when the clock is set back 2 minutes mid-segment:
What each frame does:
Without a jump, every serialized value is what the wall clock gives today, within 1ms. Stamps stay epoch millis, so the frame cache on disk and crash recovery are unchanged.
Behavior worth a look: a forward jump longer than
sessionDuration(1h) ends a session-mode recording, as reaching the cap does. Buffer mode keeps recording but drops what it buffered before the jump, so a later error doesn't send a replay spanning hours or years.Concurrency
timelineLockmakes the jump check, the re-anchor and starting a new touch-event queue one step. It is never held acrosssubmit, an SDK call or the logger.executorTimeline, the timeline the executor's queued work is on, and keeps the old timeline's touches.Compatibility: no public API change. Every constructor keeps its
ICurrentDateProvider(sentry-dart calls the 4-argReplayIntegrationconstructor), which becomes the anchor's wall clock.Not addressed here: the player lagging on the overlap after a backward jump, buffer-mode crash recovery after a jump (only the frames after it are recovered), and caller-supplied stamps in
onScreenshotRecorded(File, Long).💡 Motivation and Context
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
ICurrentDateProviderfrom the replay strategies in v9 (JAVA-827).🤖 Generated with Claude Code