File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
apps/desktop/src-tauri/src Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,8 @@ pub struct GeneralSettingsStore {
9999}
100100
101101fn default_enable_native_camera_preview ( ) -> bool {
102- // TODO:
103- // cfg!(target_os = "macos")
104- false
102+ // This will help us with testing it
103+ cfg ! ( all( debug_assertions, target_os = "macos" ) )
105104}
106105
107106fn default_enable_new_recording_flow ( ) -> bool {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ use serde_json::json;
5656use specta:: Type ;
5757use std:: collections:: BTreeMap ;
5858use std:: path:: Path ;
59+ use std:: time:: Duration ;
5960use std:: {
6061 fs:: File ,
6162 future:: Future ,
@@ -77,6 +78,7 @@ use tauri_plugin_shell::ShellExt;
7778use tauri_specta:: Event ;
7879use tokio:: sync:: mpsc;
7980use tokio:: sync:: { Mutex , RwLock } ;
81+ use tokio:: time:: timeout;
8082use tracing:: debug;
8183use tracing:: error;
8284use tracing:: trace;
@@ -286,10 +288,25 @@ async fn set_camera_input(
286288 . unwrap_or_default ( )
287289 {
288290 let ( camera_tx, camera_rx) = flume:: bounded :: < RawCameraFrame > ( 4 ) ;
289- camera_preview
290- . init_preview_window ( window, camera_rx)
291- . await
292- . unwrap ( ) ;
291+
292+ let prev_err = & mut None ;
293+ if timeout ( Duration :: from_secs ( 3 ) , async {
294+ while let Err ( err) = camera_preview
295+ . init_preview_window ( window. clone ( ) , camera_rx. clone ( ) )
296+ . await
297+ {
298+ error ! ( "Error initializing camera feed: {err}" ) ;
299+ * prev_err = Some ( err) ;
300+ tokio:: time:: sleep ( Duration :: from_millis ( 200 ) ) . await ;
301+ }
302+ } )
303+ . await
304+ . is_err ( )
305+ {
306+ let _ = window. close ( ) ;
307+ return Err ( format ! ( "Timeout initializing camera preview: {prev_err:?}" ) ) ;
308+ } ;
309+
293310 Some ( camera_tx)
294311 } else {
295312 None
You can’t perform that action at this time.
0 commit comments