From a2b7edd539a26489a7d623369b9de7887c3ca034 Mon Sep 17 00:00:00 2001 From: Freddy Saez Date: Fri, 2 Oct 2026 21:09:24 +0200 Subject: [PATCH] Don't panic syncing a browser pane whose navigation failed On macOS, WKWebView.URL becomes nil once a provisional navigation fails (unresolvable host, offline, typo). lb-wry's url_from_webview unwraps that nil, and because BrowserView::sync runs inside a GPUI task on the main dispatch queue the panic aborts the whole app. The pane is restored on every launch, so muxel crash-loops until workspace.json is edited by hand. Check that the webview has a committed URL before asking wry for it, and treat its absence like any other "nothing to sync yet" tick. Co-Authored-By: Claude Opus 5.5 --- crates/muxel/src/browser.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/muxel/src/browser.rs b/crates/muxel/src/browser.rs index 45ff681..1feb4e2 100644 --- a/crates/muxel/src/browser.rs +++ b/crates/muxel/src/browser.rs @@ -137,6 +137,19 @@ mod imp { } } + #[cfg(target_os = "macos")] + fn committed_url(webview: &wry::WebView) -> Option { + use wry::WebViewExtMacOS as _; + let url = unsafe { webview.webview().URL() }?; + url.absoluteString()?; + webview.url().ok() + } + + #[cfg(target_os = "windows")] + fn committed_url(webview: &wry::WebView) -> Option { + webview.url().ok() + } + /// IPC message the page posts when it is clicked. Namespaced so it can't /// collide with a site that uses `window.ipc` for its own purposes. #[cfg(target_os = "macos")] @@ -562,7 +575,7 @@ mod imp { /// tick so `Instance.browser_url` and the address bar stay fresh. pub fn sync(&mut self, window: &mut Window, cx: &mut Context) -> Option { let wv = self.webview.as_ref()?; - let current = wv.read(cx).url().ok()?; + let current = committed_url(wv.read(cx).raw())?; // A newly created WebView2 reports its bootstrap document before // the requested navigation commits. Persisting that transient URL // loses the resource identity and lets a fast second click create