fix(macos): Guard nil WKWebView title to prevent native SIGSEGV#23642
fix(macos): Guard nil WKWebView title to prevent native SIGSEGV#23642ajpinedam wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Defensive hardening for the macOS Skia native WebView title accessor to avoid a native crash when WKWebView.title is nil, plus a runtime test covering the “title before navigation” case.
Changes:
- Guard
WKWebView.titleagainstnilinuno_webview_get_titlebefore callingstrdup. - Add a runtime test asserting
CoreWebView2.DocumentTitlereturns""on a fresh WebView2 (no navigation yet). - Add a new SamplesApp manual test page for ContentDialog auto-focus / soft-keyboard behavior (appears unrelated to this PR’s stated scope).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23642/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23642/wasm-skia-net9/index.html |
|
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23642/wasm-skia-net9/index.html |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
7bb0e11 to
ea15d2a
Compare

GitHub Issue: #23641
PR Type:
🐞 Bugfix
What changed? 🚀
uno_webview_get_title(macOS Skia native WebView) calledstrdup(webview.title.UTF8String)directly.WKWebView.titleis nullable; when it isnil,[nil UTF8String]returnsNULLandstrdup(NULL)dereferences null →SIGSEGV. This guards it:""preserves the existing behavior:CoreWebView2.DocumentTitlealready coalesces to"",_previousTitleseeds to""(so no spuriousDocumentTitleChanged), and it matches WinUI parity (a title-less page returns""). Allocation/free ownership is unchanged (still astrdupbuffer freed by the UTF-8 return marshaller).Also adds a
When_DocumentTitle_Before_Navigationruntime test assertingDocumentTitlereturns""(rather than crashing) on a fresh web view.Scope / honesty note: this targets the intermittent macOS 26 / x64
SIGSEGVin theGiven_WebView2.When_ExecuteScriptAsync*runtime tests (#23641). The crash could not be reproduced locally (~65 runs on a matching macOS 26.4.1 / x64 machine, incl.NSZombieEnabledandMallocScribble; instrumentation showedtitlewas nevernilacross ~70 navigations). So this is a defensive nullability fix, not a confirmed root-cause fix — butWKWebView.titleis nullable by API, sostrdup(NULL)is a real latent crash worth closing regardless. Whether it resolves the CI crash will be shown by the macOS runtime-test leg; #23641 is left open until confirmed.PR Checklist ✅
When_DocumentTitle_Before_Navigation)Screenshots Compare Test Runresults — N/A (no visual change)🤖 Generated with Claude Code
https://claude.ai/code/session_0178mJtoQEwreA2zrADWUgqP