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

オープン
#6,741 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, kotlin
領域
mobile

調査の方向性

Start in sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BufferCaptureStrategy.kt at the bufferedSegments.rotate call and read how remaining segments are re-assigned IDs while videoFile stays fixed. Then read ReplayCache.kt (getReplayOrDefaultFile/createVideoOf around line 140-151) to see where the $segmentId.mp4 name is built and deleted, plus ReplayCache.fromDisk and deleteExceptSegmentVideos for the recovery path. Write the failing test first: two buffered segments, expire the first, trigger an error, and assert the buffered segment keeps its own video; done means that test passes and disk recovery still finds all videos.

索引モデルが issue の本文から書いたものです。

説明

Android Bug Platform: Java Replays

Problem

In buffer mode, an error can send a buffered segment with the wrong video.

Each video is stored at "$segmentId.mp4". When bufferedSegments.rotate removes an expired segment, it gives the remaining segments new IDs, but their videoFile does not change. Then currentSegment can be equal to the ID in the file name of a segment that is still buffered.

When an error occurs, the capture_replay task first encodes the current segment to "$currentSegment.mp4". createVideoOf deletes the file that is already there. After that, bufferedSegments.capture() sends the buffered segment, which now points to the new video.

Example

  1. Buffer mode. The user puts the app in the background. pause buffers segment 0 at 0.mp4.
  2. The user opens the app again and rotates the device. configuration_changed buffers segment 1 at 1.mp4. currentSegment is 2.
  3. 30s after step 1, segment 0 expires. The rotation deletes 0.mp4. Segment 1 gets ID 0 but keeps 1.mp4. currentSegment is 1.
  4. An error occurs before segment 1 expires. The current segment is encoded to 1.mp4, and the old content of that file is deleted.
  5. The replay sends segment 0 and segment 1 with the same video. The video of the buffered segment is lost.

Proposed fix

Give each video a file name that does not depend on the segment ID that is sent, for example a counter that only increases, or a UUID. Make sure that crash recovery (ReplayCache.fromDisk and deleteExceptSegmentVideos) still finds the videos.

First, add a test on main that fails: two buffered segments, the first one expires, then an error occurs. The buffered segment must keep its own video.

Found while reviewing #6542. The bug is on main without that PR.

主要言語
Kotlin
スター
1.4k
フォーク
483
平均マージ
2日 54分
マージ済み PR(30日)
207

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-java のほかの issue

getsentry/sentry-java の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。