Android Replay: BufferCaptureStrategy.stop() can persist replay state after deleting replay cache dir
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 70/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- android, kotlin
- Ambito
- mobile-dev
Direzione di ricerca
Inizia con BufferCaptureStrategy.kt e ReplayCache.kt, seguendo BufferCaptureStrategy.stop() attraverso il setter di currentSegment e persistSegmentValues(). Riproduci il percorso di teardown della riproduzione con buffering, soprattutto dopo aver eliminato la directory della cache di riproduzione, e verifica che l’arresto della riproduzione non registri più l’errore No such file or directory.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- Kotlin
- Stelle
- 1.4k
- Fork
- 478
- Merge medio
- 3g 2h
- PR unite (30g)
- 70
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-java
-
Improvement Java Platform: Java
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
getsentry/sentry-java#6145 · 1 commento ·
-
Bug Java Platform: Java
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-java#6138 · 1 commento ·
-
Feature Java Platform: Java Spans
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getsentry/sentry-java#5984 · 1 commento ·
-
Android Task Traces
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getsentry/sentry-java#5376 · 1 commento ·
-
Android Docs Errors
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
getsentry/sentry-java#5375 · 1 commento ·
Tutte le issue di getsentry/sentry-java
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Telegram !!! Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Xposed-Modules-Repo/com.fuck.iab#24 · 3 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
SimonHalvdansson/Harmonic-HN#361 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
johanhaleby/occurrent#1120 ·