minutes icon indicating copy to clipboard operation
minutes copied to clipboard

Native call capture: instrument stopCapture timing + skip rescue of sub-second stems from abort-at-start failures

Open silverstein opened this issue 6 months ago • 0 comments

Two follow-ons from @sjunnesson on the now-closed #216 (comment). Bundling both because they live in the same code surface (the Swift capture helper plus the rescue path in commands.rs).

1. Instrument stream.stopCapture() duration

Today we have no real distribution for how long stopCapture() takes to drain and finalize on a long-running native-call capture. The 15-second SIGKILL ceiling in #216 came in as a hard wall with no telemetry: we know finalize was still running at +15s but not how close to done it was.

Cheapest fix: wrap the try await stream.stopCapture() call in the Swift helper with a ContinuousClock.now measurement and emit the elapsed on success. One or two successful long captures gives us the duration-to-finalize curve and lets us size the heartbeat ceiling on top of empirical numbers rather than a guess.

sjunnesson has offered to run a build with the log line locally and report back.

2. Skip rescue of sub-second stems from abort-at-start failures

@sjunnesson surfaced a second failure mode distinct from #216's long-capture truncation:

  • 2026-04-07-130235-capture.mov (1,974 bytes)
  • 2026-04-08-100120-capture.mov (1,908 bytes)

Both have only ftyp / wide / qt atoms, no mdat, no moov. They pair by mtime to tiny orphan stems in ~/.minutes/native-captures/ of 38,656 and 19,456 bytes (roughly 0.1-0.2 seconds of audio). These are captures that aborted almost immediately at start, not duration-truncated finalize victims.

The current rescue path (rescue_paired_stems at tauri/src-tauri/src/commands.rs:2514) handles this without crashing because it does not parse the .mov, only walks for sibling stems. But the only filter on stem files is meta.len() == 0. A 38 KB stem passes that filter and gets moved into failed-captures/ as if it were a real recording. The result is a recovery-surface artifact the user cannot do anything useful with.

Fix: add a duration-based sanity threshold to rescue_paired_stems. Anything below ~1 second of audio (~96,000 bytes at 48kHz mono 16-bit) gets logged and skipped rather than rescued. The threshold should be conservative enough not to drop short legit voice memos but tight enough to catch the abort-at-start fragments.

Scope

Both are small follow-ons, not blockers. Slate for v0.17.4 or v0.17.5.

Reported by @sjunnesson on #216 after the original fix shipped in v0.17.1.

silverstein avatar May 12 '26 14:05 silverstein