-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: speed test and health check for desktop app #1659
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 |
|---|---|---|
|
|
@@ -923,17 +923,34 @@ pub async fn start_recording( | |
| return Err(anyhow!("Video upload info not found")); | ||
| }; | ||
|
|
||
| let settings_resolution = general_settings | ||
| .as_ref() | ||
| .map(|settings| settings.instant_mode_max_resolution) | ||
| .unwrap_or(1920); | ||
|
|
||
| let speed_test_resolution = { | ||
| let network_state = app_handle | ||
| .state::<std::sync::Arc<tokio::sync::RwLock<crate::speed_test::NetworkState>>>(); | ||
| let state = network_state.read().await; | ||
| match &state.speed_test_status { | ||
| crate::speed_test::SpeedTestStatus::Completed(result) => { | ||
| Some(result.recommended_quality.max_resolution()) | ||
| } | ||
| _ => None, | ||
| } | ||
| }; | ||
|
|
||
| let max_resolution = match speed_test_resolution { | ||
| Some(speed_res) => settings_resolution.min(speed_res), | ||
| None => settings_resolution, | ||
| }; | ||
|
|
||
| let mut builder = instant_recording::Actor::builder( | ||
| recording_dir.clone(), | ||
| inputs.capture_target.clone(), | ||
| ) | ||
| .with_system_audio(inputs.capture_system_audio) | ||
| .with_max_output_size( | ||
| general_settings | ||
| .as_ref() | ||
| .map(|settings| settings.instant_mode_max_resolution) | ||
| .unwrap_or(1920), | ||
| ); | ||
| .with_max_output_size(max_resolution); | ||
|
|
||
| #[cfg(target_os = "macos")] | ||
| { | ||
|
|
@@ -1044,6 +1061,8 @@ pub async fn start_recording( | |
| let _ = RecordingEvent::Started.emit(&app); | ||
| let _ = RecordingStarted.emit(&app); | ||
|
|
||
| crate::speed_test::set_recording_active(&app, true).await; | ||
|
|
||
| spawn_actor({ | ||
| let app = app.clone(); | ||
| let state_mtx = Arc::clone(&state_mtx); | ||
|
|
@@ -1235,6 +1254,8 @@ fn mic_actor_not_running(err: &anyhow::Error) -> bool { | |
| #[specta::specta] | ||
| #[instrument(skip(app, state))] | ||
| pub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Result<(), String> { | ||
| crate::speed_test::set_recording_active(&app, false).await; | ||
|
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. Minor logic bug: setting |
||
|
|
||
| let mut state = state.write().await; | ||
| let Some(current_recording) = state.clear_current_recording() else { | ||
| return Err("Recording not in progress".to_string())?; | ||
|
|
||
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.
Recording failure leaves speed test permanently blocked
When a recording fails or crashes (the error path in
spawn_actorat line ~1078),set_recording_active(&app, false)is never called. The flag is set totrueat line 1064, but onlystop_recording(line 1257) resets it tofalse. If the recording actor errors out via theErr(e)branch,is_recordingstaystrueforever, permanently blocking the speed test with "Cannot run speed test during an active recording".You should reset the flag in the error handler as well:
Prompt To Fix With AI