Repository navigation
Conversation
finalizePreviousReplay runs once on the shared executor and can run late, e.g. behind ANR processing. cleanupReplays then deleted every replay folder except the current replay id, which is empty after stop(), so it removed the folder of a replay that had just stopped, including segment videos the transport had not read yet. It could also read this process's replay id from the persisted scope after a flush and treat it as a previous replay to recover, which deletes the folder of the running replay. Track the replay ids started in this process, keep their folders in the cleanup and skip finalizing them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
ConcurrentHashMap.newKeySet() requires API 24 and the min SDK is 21. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romtsn
marked this pull request as ready for review
October 21, 2026 13:21
romtsn
requested review from
0xadam-brown,
adinauer,
markushi and
runningcode
as code owners
October 21, 2026 13:21
runningcode
approved these changes
Oct 21, 2026
runningcode
left a comment
Contributor
There was a problem hiding this comment.
Very nice find! I wonder if we have any other bugs due to that executor being busy!
markushi
reviewed
Oct 21, 2026
| private val state = AtomicReference(ReplayState()) | ||
| // Replays recorded by this process. Their folders hold segment videos the transport may still | ||
| // read after the replay stopped, so the startup cleanup of previous replays must keep them. | ||
| private val replayIdsOfThisProcess = CopyOnWriteArraySet<String>() |
Member
There was a problem hiding this comment.
shouldn't this be static? E.g. a second SDK init would create a new ReplayIntegration, right?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
The startup cleanup of previous replays no longer deletes replays recorded by the current process.
finalizePreviousReplay()runs once, atregister(), on the sharedoptions.executorService. That executor can be busy at startup (on an emulator I saw ANR processing hold it for about 10 s), so the task can run after the app has already started, flushed and stopped a replay. Two things then went wrong:cleanupReplays()deleted everyreplay_*folder except the currentreplayIdand the previous process's unfinished replay. Afterstop()the currentreplayIdis empty, so it deleted the folder of the replay that had just stopped, including segment videos the transport had not read yet. The segment was sent without video.replay.jsonwhen a replay is captured. If the task ran after a flush, it read this process's replay id as the "previous" replay and tried to recover it. That either deletes the running replay's folder (noongoing_segmentyet) or sends a recovered segment with the previous-replay flag, which deletes the whole folder after it is serialized.ReplayIntegrationnow keeps the ids of the replays it started in this process.cleanupReplays()keeps their folders, andfinalizePreviousReplay()skips an id from this process. Their folders still go away as before: the transport deletes each video after sending it, and leftovers are cleaned up on the next launch.💡 Motivation and Context
Found while verifying #6340 on an emulator: with an early
startBuffering()→flush()→stop(), the startup task ran right afterstop()and deleted the replay folder before the transport read segment 0.💚 How did you test it?
Two tests in
ReplayIntegrationTesthold back the startup task, record and stop a replay, then run the task:delayed startup cleanup keeps replays recorded by this process— the stopped replay's video survives, an older replay folder is still deleted.delayed startup task does not finalize a replay recorded by this process— with this replay's id inreplay.json, nothing is captured and the folder survives.Both fail without the fix. Not verified on a device: the race needs the startup executor to be blocked, which I could not trigger on demand.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
🤖 Generated with Claude Code