From 870ffdf59a8a358749a3ec22e3092e86434dd569 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 11 Jul 2022 08:03:37 -0700 Subject: [PATCH] ensure that we spawn open calls on a background thread Otherwise we can block the gui waiting for eg: a freshly opened firefox to terminate. See also comment worrying about this in 75066cb52254cb7dd673c541c8e5fcce03943529. That fear was realized but now resolved! refs: https://github.com/wez/wezterm/issues/2245 --- docs/changelog.md | 1 + lua-api-crates/spawn-funcs/src/lib.rs | 8 +++++--- wezterm-gui/src/termwindow/mod.rs | 10 ++++++---- wezterm-toast-notification/src/dbus.rs | 5 ++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index f62e2197f..990fdfb8b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -43,6 +43,7 @@ As features stabilize some brief notes about them will accumulate here. * Tab bar could show a gap to the right when resizing * Padding could show window background rather than pane background around split panes at certain window sizes [#2210](https://github.com/wez/wezterm/issues/2210) * Loading dynamic escape sequence scripts from the [iTerm2-Color-Scheme dynamic-colors directory](https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/dynamic-colors) would only apply the first 7 colors +* Unix: Clicking a URL when no browser is open could cause wezterm to hang until the newly opened browser is closed. [#2245](https://github.com/wez/wezterm/issues/2245) #### Updated * Bundled harfbuzz to 4.4.1 diff --git a/lua-api-crates/spawn-funcs/src/lib.rs b/lua-api-crates/spawn-funcs/src/lib.rs index fb84f0c59..245009487 100644 --- a/lua-api-crates/spawn-funcs/src/lib.rs +++ b/lua-api-crates/spawn-funcs/src/lib.rs @@ -20,9 +20,11 @@ fn open_with<'lua>(_: &'lua Lua, (url, app): (String, Option)) -> mlua:: if let Some(app) = app { open::with_in_background(url, app); } else { - if let Err(err) = open::that(&url) { - log::error!("Error opening {}: {:#}", url, err); - } + std::thread::spawn(move || { + if let Err(err) = open::that(&url) { + log::error!("Error opening {}: {:#}", url, err); + } + }); } Ok(()) } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 61c5e6ab4..f08c63bcc 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -2519,10 +2519,12 @@ impl TermWindow { None => true, }; if default_click { - log::info!("clicking {}", link); - if let Err(err) = open::that(&link) { - log::error!("Error opening {}: {:#}", link, err); - } + std::thread::spawn(move || { + log::info!("clicking {}", link); + if let Err(err) = open::that(&link) { + log::error!("Error opening {}: {:#}", link, err); + } + }); } Ok(()) } diff --git a/wezterm-toast-notification/src/dbus.rs b/wezterm-toast-notification/src/dbus.rs index 8eb1779b2..b051e35ca 100644 --- a/wezterm-toast-notification/src/dbus.rs +++ b/wezterm-toast-notification/src/dbus.rs @@ -126,7 +126,10 @@ async fn show_notif_impl(notif: ToastNotification) -> Result<(), Box