Android Replay: BufferCaptureStrategy.stop() can persist replay state after deleting replay cache dir
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- android, kotlin
- Área
- mobile-dev
Línea de trabajo
Comienza con BufferCaptureStrategy.kt y ReplayCache.kt, siguiendo BufferCaptureStrategy.stop() a través del setter de currentSegment y persistSegmentValues(). Reproduce la ruta de desmontaje de la reproducción en búfer, especialmente después de eliminar el directorio de caché de reproducción, y verifica que detener la reproducción ya no registre el error No such file or directory.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- Kotlin
- Estrellas
- 1.4k
- Forks
- 478
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 71
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-java
-
Improvement Java Platform: Android Platform: Java
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
getsentry/sentry-java#6145 · 1 comentario · 1 asignado ·
-
Bug Java Platform: Android Platform: Java
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-java#6138 · 1 comentario ·
-
Feature Java Platform: Java Spans
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
getsentry/sentry-java#5984 · 1 comentario ·
-
Android Task Traces
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
getsentry/sentry-java#5376 · 1 comentario ·
-
Android Docs Errors
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
getsentry/sentry-java#5375 · 1 comentario ·
Todos los issues de getsentry/sentry-java
Issues similares
-
[Bug] 统计页面无法重置token和汇率 Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
AAswordman/Operit#1265 · 3 comentarios ·
-
Tambahkan bahasa Indonesia Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
libre-tube/LibreTube#8803 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
status: waiting-for-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
spring-projects/spring-security#19781 ·