Android Replay: BufferCaptureStrategy.stop() can persist replay state after deleting replay cache dir
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- android, kotlin
- 領域
- mobile-dev
調査の方向性
BufferCaptureStrategy.kt と ReplayCache.kt から始め、currentSegment setter と persistSegmentValues() を経由して BufferCaptureStrategy.stop() を追跡します。特に replay cache ディレクトリを削除した後の、バッファリングされた replay の teardown パスを再現し、replay を停止しても No such file or directory エラーがログに記録されなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
Android Session Replay can throw an internal error during replay teardown:
Failed to execute task CaptureStrategy.runInBackground
java.io.IOException: No such file or directory
...
at io.sentry.android.replay.ReplayCache.persistSegmentValues
...
at io.sentry.android.replay.capture.BufferCaptureStrategy.stop
This appears to happen when stopping a buffering replay.
Likely root cause
BufferCaptureStrategy.stop() currently deletes the replay cache directory and then updates replay state in the same task:
- delete replay cache dir
- set
currentSegment = -1
The currentSegment setter persists state through ReplayCache.persistSegmentValues(...).
On the replay worker thread, that persistence runs inline, so it can try to recreate/write .ongoing_segment after the replay directory has already been deleted.
That leads to:
java.io.IOException: No such file or directory
at java.io.File.createNewFile
at io.sentry.android.replay.ReplayCache.persistSegmentValues
Why this matters
This is at least noisy internal error logging, but it may also contribute to brittle replay lifecycle behavior in manual/custom flows that use combinations of:
flush()pause()stop()startBuffering()
In our investigation, this showed up while testing a custom User Feedback + Replay workaround, where replay behavior was already timing-sensitive.
Relevant code path
Conceptually, the flow is:
BufferCaptureStrategy.stop()FileUtils.deleteRecursively(replayCacheDir)currentSegment = -1persistSegmentValues(...)ongoingSegmentFile?.createNewFile()- parent folder no longer exists
Expected behavior
Stopping replay should not try to persist replay state into a directory that has already been deleted.
Actual behavior
Replay teardown logs No such file or directory from ReplayCache.persistSegmentValues.
Suggested fix direction
Any of these would likely resolve it:
- clear/persist mutable state before deleting the replay directory
- mark the cache closed before state mutation can persist
- guard
persistSegmentValuesagainst a missing/deleted parent directory during teardown - avoid persisting teardown sentinel values like
currentSegment = -1once shutdown has begun
Customer-visible context
This was observed during a real customer reproduction involving Android Session Replay plus custom in-app User Feedback, where the workaround flow exercised replay stop/restart behavior repeatedly.
Logs
Failed to execute task CaptureStrategy.runInBackground
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively0(Native Method)
at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:373)
at java.io.File.createNewFile(File.java:1022)
at io.sentry.android.replay.ReplayCache.persistSegmentValues$sentry_android_replay_release(ReplayCache.kt:290)
at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$2$2.invoke(BaseCaptureStrategy.kt:240)
at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$2.runInBackground(BaseCaptureStrategy.kt:227)
at io.sentry.android.replay.capture.BaseCaptureStrategy$special$$inlined$persistableAtomic$default$2.setValue(BaseCaptureStrategy.kt:239)
at io.sentry.android.replay.capture.BaseCaptureStrategy.setCurrentSegment(BaseCaptureStrategy.kt:88)
at io.sentry.android.replay.capture.BufferCaptureStrategy.stop$lambda$0(BufferCaptureStrategy.kt:84)
- 主要言語
- Kotlin
- スター
- 1.4k
- フォーク
- 478
- 平均マージ
- 3日 2時間
- マージ済み PR(30日)
- 70
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-java のほかの issue
-
Bug Java Platform: Java
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-java#6138 · コメント 1 件 ·
-
Feature Java Platform: Java Spans
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-java#5984 · コメント 1 件 ·
-
Android Task Traces
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-java#5376 · コメント 1 件 ·
-
Android Docs Errors
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
getsentry/sentry-java#5375 · コメント 1 件 ·
-
Android good first issue Task User Feedbacks
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-java#5354 · コメント 1 件 ·
getsentry/sentry-java の issue をすべて見る
似ている issue
-
Icon Requests オープンsupported
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
LawnchairLauncher/lawnicons#4100 ·
-
cr:missing-repro cr:platform:android platform:android repro-provided
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
software-mansion/react-native-screens#4699 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
Good First Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
ankidroid/Anki-Android#21942 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
libre-tube/LibreTube#8781 · コメント 1 件 ·