Fix desktop recordings losing their last segment on a slow finalize, and measure clips at the Stop click - #6
Merged
Conversation
…g last segment, and measure the clip at the Stop click Every multi-segment recording whose final ScreenCaptureKit finalize took longer than SCK_FINALIZE_TIMEOUT lost its last segment: the instant playability check saw no moov, quarantined the file, and subtracted the time from duration_ms — so the clip uploaded "complete" minus its last 2–4.5 minutes and nothing flagged it. All three quarantined files on this machine are fully playable today; the writer finished the moov after the rename. Segment recovery now gives a still-flushing writer up to SEGMENT_MOOV_GRACE (20s) before judging it, matching the budget rotated writers already get. Separately, duration_ms was computed after the finalize wait, deferred writers and the segment merge, so every slow stop ran 10–17s long and the pre-upload duration gate reported complete clips as truncated (the 17s and 12s "may be incomplete" cases). The clip is now measured at the Stop request; pause likewise starts at the request, not after its finalize wait. multi_segment is read before consolidation collapses the list so the session-finalized diag stops reporting every multi-segment recording as single; the event also carries lost segment totals. The webview's lost-event guard for the finalized event outlasts the new ceiling, since firing early is the -5814 interruption that corrupts the moov.
Visual recap — skippedThe visual recap job did not run for this pull request. This is informational only and does not block the PR. Recap skipped for |
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.
Follow-up to #4's "Not fixed" section: the segment-rollover truncation. It turned out to be two defects, both in the native stop path, and both visible in
tray-timings.log.1. A slow final finalize dropped the last segment (real data loss)
Every multi-segment recording whose final ScreenCaptureKit finalize took longer than
SCK_FINALIZE_TIMEOUT(10 s) lost its last segment.recover_from_unusable_current_segmentran an instant playability check right after the timeout, saw nomoov, popped the segment, quarantined the file and subtracted its time fromduration_ms— so the clip uploaded "complete" minus its last 2–4.5 minutes, wall-clock and media agreed, and nothing flagged it.Evidence: all three quarantine events in the local log happen exactly ~10.2–10.5 s after
stop-begin, and all three quarantined files inlost-segments/are fully playable today (124 s / 271 s / 166 s per ffprobe — the writer finished the moov after the rename):bqhlKZC61Tz8JJu2NjjKSGHCQ5N0xi0KgLm7Fix: segment recovery gives a still-flushing writer up to
SEGMENT_MOOV_GRACE(20 s) to land its moov before judging it, matching the budget parked rotation writers already get inresolve_deferred_finalizes. The single-segment path already did this (wait_for_mp4_moov8 s before "still being finalized, retry"); the multi-segment path was the sibling that didn't.2.
duration_msincluded the stop latency (the "17 s / 12 s shorter" false alarms)duration_mswas computed after the finalize wait, the deferred writers and the segment merge, so every slow stop ran 10–17 s long and the pre-upload duration gate reported complete clips as truncated:zzBTjeZJF53G: 165.7 s wall-clock,session-finalized ms:10752, media 164.4 s → "12 s shorter"It89xpTan1cr: 18 s + pause + 147 s + 241 s = 406 s,session-finalized ms:16626, media 405.5 s → "17 s shorter"Both clips are complete; their "Clip may be incomplete" editor-notes are false alarms. The clip is now measured at the Stop request; pause likewise starts at the request rather than after its own finalize wait, and lost-segment accounting uses the same request-time measurement.
Also
multi_segmentis read before consolidation collapses the list, sosession-finalizedstops reporting every multi-segment recording asmultiSegment:false; the event also carriesdurationMs/lostSegments/lostMs.clips:native-recording-finalized(was 15 s) now outlasts the new Rust ceiling — firing early is the -5814 interruption that corrupts the moov.Verification
vite buildOK.Not done here
Lost segments are still only loud in
tray-timings.logand stderr. When a tail is genuinely unrecoverable the user should see it on the clip (the same editor-note mechanism #4 added for short clips); that needslost_msthreaded throughNativeFullscreenUploadResult.