Skip to content

fix(macos): avoid panics on missing URL (fix #1752)#1753

Open
Buncys wants to merge 1 commit into
tauri-apps:devfrom
Buncys:fix/macos-url-unwrap
Open

fix(macos): avoid panics on missing URL (fix #1752)#1753
Buncys wants to merge 1 commit into
tauri-apps:devfrom
Buncys:fix/macos-url-unwrap

Conversation

@Buncys

@Buncys Buncys commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR removes unwrap calls in two code paths, as requested in #1752.

Affected code paths

  • src/wkwebview/mod.rs, url_from_webview()
  • src/wkwebview/navigation.rs, navigation_policy()

Changes

  • url_from_webview() now returns Ok("") when URL is unavailable, which is consistent with other platforms
  • Navigation will be canceled instead of panicking, when URL is unavailable in navigation_policy()

Fixes #1752

@Buncys Buncys requested a review from a team as a code owner June 17, 2026 19:02
@Buncys Buncys force-pushed the fix/macos-url-unwrap branch from c21dc63 to 1530e67 Compare June 17, 2026 19:09
@Buncys Buncys force-pushed the fix/macos-url-unwrap branch from 1530e67 to fd445e9 Compare June 18, 2026 13:58
@sftse

sftse commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Fixes to non-trivial issues are nearly impossible to judge without a reproducer.

@Buncys

Buncys commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Here is the reproducer:

let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
let web_view = WebViewBuilder::new().build(&window).unwrap();
let _ = dbg!(web_view.url()); // <- panics on macos

Running this produces:

thread 'main' panicked at .../wry-0.55.1/src/wkwebview/mod.rs:1349:40:
called `Option::unwrap()` on a `None` value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: avoid panic when WKWebView or navigation request URL is nil

3 participants