Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Android Replay: BufferCaptureStrategy.stop() can persist replay state after deleting replay cache dir

Aperta
#6,094 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

Android Bug Platform: Java Replays
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 = -1
  • persistSegmentValues(...)
  • 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 persistSegmentValues against a missing/deleted parent directory during teardown
  • avoid persisting teardown sentinel values like currentSegment = -1 once 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-java

Tutte le issue di getsentry/sentry-java

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.