minutes icon indicating copy to clipboard operation
minutes copied to clipboard

`minutes stop` leaves the screen-capture thread running: recorder hangs in join while screenshots continue post-meeting

Open rymalia opened this issue 4 months ago • 4 comments

Summary: Stopping a recording via the minutes stop CLI (stop-sentinel path) never signals the screen-capture thread. The recorder's main thread then blocks in ScreenCaptureHandle::drop → join() while the thread keeps screenshotting the desktop every interval_secs — after the meeting has ended — until it hits MAX_SCREENSHOTS=60 (~15 min at the default 15s interval). Privacy issue plus an apparently-hung recorder process.

Mechanism:

  • crates/core/src/capture.rs (~line 1636): the record loop exits on the stop sentinel with break, without setting stop_flag.
  • The capture thread in crates/core/src/screen.rs only watches stop_flag (or the 60-frame cap).
  • ScreenCaptureHandle::drop (screen.rs ~line 260) is a bare join() with no stop signal of its own.

Observed (real run, 2026-07-09): recording stopped at 1:51; screenshots continued past frame 33 (8:45+ elapsed); the main thread was sampled sitting in _pthread_join; sending SIGINT (the Ctrl-C path, which does set stop_flag) unstuck it immediately and processing completed normally. The desktop app's own stop button is unaffected — it sets stop_flag in-process (tauri/src-tauri/src/commands.rs, request_stop).

Suggested fix: set stop_flag when the stop sentinel is detected (both sentinel check sites), and/or give ScreenCaptureHandle its own AtomicBool that drop sets before joining, so the handle is safe regardless of the caller's flag discipline.

Interaction with PR #421: pre-existing bug (not introduced there), but that PR's retention fix means the post-meeting frames now persist to disk, so the privacy surface is larger once it lands.

rymalia avatar Jul 10 '26 07:07 rymalia

Confirmed your diagnosis against current main — it's exactly right: the record loop's stop-sentinel break (capture.rs) never sets stop_flag, the capture thread only watches thread_stop/the 60-frame cap (screen.rs:105), and ScreenCaptureHandle::drop is a bare join() (screen.rs:250) with no stop of its own. So on minutes stop the thread runs to the cap while drop blocks. Privacy issue + apparent hang, both real.

This one's in the core recording lifecycle (distinct from your #421 retention/delivery work), and it's privacy-sensitive, so I'll take this one now — the fix is to make ScreenCaptureHandle::drop signal its own stop before joining (self-contained, so no caller path can leak it), plus set the flag on the sentinel break. Shout if you're already mid-fix on it and I'll back off. Thanks for the precise write-up.

silverstein avatar Jul 10 '26 17:07 silverstein

Shout! 🙋 I'd like to take this one — I'm still deep in this exact code from #421 and have the fix mapped to the shape you describe:

  • ScreenCaptureHandle owns its own stop flag, set in Drop before the join() — self-contained, so no caller break path can leak the thread (that includes the safety-guard auto-stop breaks, which have the same latent leak as the sentinel path).
  • The sentinel break in both record loops additionally sets stop_flag, so everything else watching that flag winds down promptly too.
  • Regression test that dropping the handle stops the thread without the external flag ever being set.

Per your grouping on #424, I'll deliver both in one PR — aiming for later today.

rymalia avatar Jul 10 '26 17:07 rymalia

All yours — and your plan is better than what I'd sketched: catching that the safety-guard auto-stop breaks carry the same latent leak as the sentinel path is the right instinct (self-contained Drop covers all of them), and folding #424 in with a screen_context.unavailable event on events.jsonl is a nice touch — that gives agents and the app a live signal, not just a log line. I've stood down on this (no competing branch). Ping me when the PR's up and I'll review #423 + #424 together. Thanks for owning it.

silverstein avatar Jul 10 '26 17:07 silverstein

Fix is up: #427. As proposed: ScreenCaptureHandle owns a stop flag that Drop sets before the join() (covers the safety-guard and reconnect-failure breaks too, which had the same latent leak), and the sentinel breaks in both record loops now set the shared flag. Includes a regression test, and verified against the original repro — the recorder now exits within seconds of minutes stop instead of blocking in pthread_join while screenshotting toward the 60-frame cap.

rymalia avatar Jul 10 '26 18:07 rymalia