fix(macos): avoid panicking on missing webview URL#1729
Conversation
Do you have an example when this is the case? In all these years i don't think i've ever seen it. Of course, getting rid of unwrap is always good, just wondering. |
|
I ran into this too I think when trying to serve content with foliate-js in my tauri app, but still digging in. It paginates by loading each chapter into a sandboxed iframe from a blob URL: In a Tauri app on macOS, it triggers |
|
I have a concrete instance now, though not a minimal repro yet. Environment:
The app had a visible Relevant stack: |
Package Changes Through 17272ebThere are 1 changes which include wry with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
🤖 Sent by my AI agent on behalf of @gilgtm.
Why
On macOS and iOS,
WKWebView.URL()can be nil. Wry currently unwraps that optional value inWebView::url, which can panic the host process instead of returning an error to the caller.What
Error::IowhenWKWebView.URL()is unavailableError::Iowhen the URL cannot produce an absolute stringRisk Assessment
Low — this only changes the failure path for the Darwin URL getter. The existing successful URL conversion path is unchanged.
References
Validated locally on macOS:
cargo fmt --checkcargo checkcargo testGenerated with Codex