File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -424,17 +424,22 @@ tauri::Builder::default()
424424 crate :: vibrancy:: set_window_effects ( & window, Some ( effects) ) ?;
425425 }
426426
427- app_manager. webview . eval_script_all ( format ! (
428- "window.__TAURI_INTERNALS__.metadata.windows = {window_labels_array}.map(function (label) {{ return {{ label: label }} }})" ,
429- window_labels_array = serde_json:: to_string( & app_manager. window. labels( ) ) ?,
430- ) ) ?;
431-
432- app_manager. emit (
433- "tauri://window-created" ,
434- Some ( crate :: webview:: CreatedEvent {
435- label : window. label ( ) . into ( ) ,
436- } ) ,
437- ) ?;
427+ let app_manager = self . manager . manager_owned ( ) ;
428+ let window_label = window. label ( ) . to_string ( ) ;
429+ // run on the main thread to fix a deadlock on webview.eval if the tracing feature is enabled
430+ let _ = window. run_on_main_thread ( move || {
431+ let _ = app_manager. webview . eval_script_all ( format ! (
432+ "window.__TAURI_INTERNALS__.metadata.windows = {window_labels_array}.map(function (label) {{ return {{ label: label }} }})" ,
433+ window_labels_array = serde_json:: to_string( & app_manager. window. labels( ) ) . unwrap( ) ,
434+ ) ) ;
435+
436+ let _ = app_manager. emit (
437+ "tauri://window-created" ,
438+ Some ( crate :: webview:: CreatedEvent {
439+ label : window_label,
440+ } ) ,
441+ ) ;
442+ } ) ;
438443
439444 Ok ( window)
440445 }
You can’t perform that action at this time.
0 commit comments