Skip to content

fix(replay): Use unique video filenames for buffered segments - #6854

Open
sahuadarsh0 wants to merge 2 commits into
getsentry:mainfrom
sahuadarsh0:fix/6741-buffered-segment-video-filename
Open

sahuadarsh0 wants to merge 2 commits into
getsentry:mainfrom
sahuadarsh0:fix/6741-buffered-segment-video-filename

Conversation

@sahuadarsh0

Copy link
Copy Markdown

📜 Description

Passes a unique ${SentryId()}.mp4 filename when creating segments in BufferCaptureStrategy, threaded through BaseCaptureStrategy.createSegmentInternal and CaptureStrategy.createSegment into ReplayCache.createVideoOf.

💡 Motivation and Context

In buffer mode, bufferedSegments.rotate renumbers surviving segments and decrements currentSegment without renaming their existing .mp4 files. When an error triggers captureReplay, encoding the current segment to $currentSegment.mp4 overwrites a buffered segment's video file before bufferedSegments.capture() sends it.

Using ${SentryId()}.mp4 in BufferCaptureStrategy decouples buffered video filenames from segmentId so rotated segments can't collide with newly encoded buffered segments, post-conversion SessionCaptureStrategy segments ($segmentId.mp4), or crash-recovered segments from ReplayCache.fromDisk. ReplayCache.deleteExceptSegmentVideos continues to keep all .mp4 files, and ReplayCache.createVideoOf's public API and default filename stay unchanged.

💚 How did you test it?

Added a regression test in BufferCaptureStrategyTest (buffered segment keeps its own video after earlier segment expires) that fails on main when segment 0 expires, segment 1 is renumbered to 0, and captureReplay encodes segment 1 over 1.mp4, and passes with the fix. Updated ReplaySmokeTest.works in buffer mode to assert the .mp4 extension, and ran :sentry-android-replay:testReleaseUnitTest (capture, smoke, cache, integration, ANR suites), :sentry-android-replay:detekt, and :sentry-android-replay:spotlessCheck.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • Changelog entry starts with the product it affects, e.g. Session Replay:, Android:, Backend: or Core: (see CONTRIBUTING.md).
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

@sahuadarsh0
sahuadarsh0 requested review from a team and adinauer as code owners December 4, 2026 01:58
@sahuadarsh0
sahuadarsh0 requested review from markushi and runningcode and removed request for a team December 4, 2026 01:58
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 1d68171.

Main concerns: data sent to Sentry, reach, public contract.

This label is a hint for reviewers, not an approval.

…ment-video-filename

# Conflicts:
#	sentry-android-replay/src/test/java/io/sentry/android/replay/capture/BufferCaptureStrategyTest.kt
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session Replay: buffered segment can be sent with the wrong video after buffer rotation

1 participant