Repository navigation
fix(desktop-gpui): hold the start cue until capture is ready (Instant mode lost openings) #3036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -440,6 +440,10 @@ pub struct RecordingSession { | |
| /// A capture pipeline that finished warming up while the countdown or the | ||
| /// start cue was still running; activated the moment the cue ends. | ||
| primed: Option<ActiveRecording>, | ||
| /// Flips to `true` once the current start's capture pipeline is built. | ||
| /// The start cue waits on it, so the cue never plays while start-up | ||
| /// (e.g. Instant mode creating the shareable link) is still in flight. | ||
| engine_ready: tokio::sync::watch::Sender<bool>, | ||
| /// Teardown of a cancelled primed start still releasing its devices; the | ||
| /// next start waits for it before locking the mic and camera again. | ||
| discarding: Option<Task<Result<(), tokio::task::JoinError>>>, | ||
|
|
@@ -488,6 +492,7 @@ impl RecordingSession { | |
| start_gate: None, | ||
| start_cue: None, | ||
| primed: None, | ||
| engine_ready: tokio::sync::watch::channel(false).0, | ||
| discarding: None, | ||
| pause_control: PauseControlState::default(), | ||
| pause_control_error: None, | ||
|
|
@@ -665,6 +670,7 @@ impl RecordingSession { | |
| self.start_gate = Some(start_gate); | ||
| self.start_cue = Some(crate::app_sounds::prime_recording_start_sound()); | ||
| self.discard_primed(cx); | ||
| self.engine_ready.send_replace(false); | ||
| self.pause_control.invalidate(); | ||
| self.pause_control.uncertain = false; | ||
| self.pause_control_error = None; | ||
|
|
@@ -750,12 +756,17 @@ impl RecordingSession { | |
| ) -> std::pin::Pin<Box<dyn Future<Output = ()>>> { | ||
| let gate = self.start_gate.clone().unwrap_or_default(); | ||
| let cue = self.start_cue.take(); | ||
| let mut engine_ready = self.engine_ready.subscribe(); | ||
| let (abort, registration) = futures_util::future::AbortHandle::new_pair(); | ||
| self.countdown_cue_abort = Some(abort); | ||
| let task = gpui_tokio::Tokio::spawn( | ||
| cx, | ||
| futures_util::future::Abortable::new( | ||
| async move { | ||
| // The cue tells the user recording has started, so hold it | ||
| // until capture can actually begin. A failed start aborts | ||
| // this future through `abort_start_cue`. | ||
| let _ = engine_ready.wait_for(|ready| *ready).await; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new wait has no test that exercises it. Existing countdown tests check Add tests that hold readiness false, release it, and cancel or fail while waiting. Check that neither the cue nor the gate fires early and that an old attempt cannot release a new cue. Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/desktop-gpui/src/session.rs
Line: 769
Comment:
**Readiness wait has no tests**
The new wait has no test that exercises it. Existing countdown tests check `countdown_advance`, and the stop test installs an abort handle without starting `play_start_cue`. The timing behavior this fix depends on could regress without those tests catching it.
Add tests that hold readiness false, release it, and cancel or fail while waiting. Check that neither the cue nor the gate fires early and that an old attempt cannot release a new cue.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| match cue { | ||
| Some(cue) => crate::app_sounds::play_recording_start_sound(cue, gate).await, | ||
| None => { | ||
|
|
@@ -840,6 +851,7 @@ impl RecordingSession { | |
| } | ||
| match result { | ||
| Ok(Ok(active)) => { | ||
| this.engine_ready.send_replace(true); | ||
| if this.countdown_remaining.is_some() { | ||
| this.primed = Some(active); | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wait can outlast the gate’s 20-second failsafe. The gate is created before
prepare_instant_upload, so a slow request such as the reported 102-second case leaves it expired when capture starts. The first media check then opens the gate before the delayed cue finishes. The cue’s laterarm()cannot replace that start time, so the saved recording can include the cue and unwanted lead-in.Keep the gate closed through the readiness wait, and start its failsafe clock when capture is ready.
Prompt To Fix With AI