Skip to content

fix(macos): Guard nil WKWebView title to prevent native SIGSEGV - #23642

Merged
ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/investigate.crash.macos26.x64
Jul 6, 2026
Merged

ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/investigate.crash.macos26.x64

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: #23641

PR Type:

🐞 Bugfix

What changed? 🚀

uno_webview_get_title (macOS Skia native WebView) called strdup(webview.title.UTF8String) directly. WKWebView.title is nullable; when it is nil, [nil UTF8String] returns NULL and strdup(NULL) dereferences null → SIGSEGV. This guards it:

NSString *title = webview.title ?: @"";
return strdup(title.UTF8String);

"" preserves the existing behavior: CoreWebView2.DocumentTitle already coalesces to "", _previousTitle seeds to "" (so no spurious DocumentTitleChanged), and it matches WinUI parity (a title-less page returns ""). Allocation/free ownership is unchanged (still a strdup buffer freed by the UTF-8 return marshaller).

Also adds a When_DocumentTitle_Before_Navigation runtime test asserting DocumentTitle returns "" (rather than crashing) on a fresh web view.

Scope / honesty note: this targets the intermittent macOS 26 / x64 SIGSEGV in the Given_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. NSZombieEnabled and MallocScribble; instrumentation showed title was never nil across ~70 navigations). So this is a defensive nullability fix, not a confirmed root-cause fix — but WKWebView.title is nullable by API, so strdup(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 ✅

  • 🧪 Added a runtime test (When_DocumentTitle_Before_Navigation)
  • 📚 Docs — N/A (internal native fix, no public API change)
  • 🖼️ Validated PR Screenshots Compare Test Run results — N/A (no visual change)
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests

🤖 Generated with Claude Code

https://claude.ai/code/session_0178mJtoQEwreA2zrADWUgqP

Copilot AI review requested due to automatic review settings July 3, 2026 19:23
@github-actions github-actions Bot added platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform area/automation Categorizes an issue or PR as relevant to project automation labels Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.title against nil in uno_webview_get_title before calling strdup.
  • Add a runtime test asserting CoreWebView2.DocumentTitle returns "" 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.

File Description
src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOWebView.m Prevents strdup(NULL) by coalescing nullable WKWebView.title to an empty string.
src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_WebView2.cs Adds regression coverage for reading DocumentTitle before any navigation.
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml/FocusManager/ContentDialog_AutoFocusTextBox.xaml.cs Adds a new manual sample page (also contains a build-breaking unused using).
src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml/FocusManager/ContentDialog_AutoFocusTextBox.xaml XAML UI for the new manual sample page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 3, 2026 22:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 220694 has failed on Uno.UI - CI.

Copilot AI review requested due to automatic review settings July 4, 2026 05:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 4, 2026 22:41
@ajpinedam
ajpinedam force-pushed the dev/anpi/investigate.crash.macos26.x64 branch from 7bb0e11 to ea15d2a Compare July 4, 2026 22:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

jonpryor added a commit that referenced this pull request Jul 6, 2026
Context: #23622
Context: #23642

**Tests - Desktop Skia macOS > Runtime Tests > Run macOS Runtime Tests**
regularly crashes on CI *when using macos-26*:

	info: Uno.UI.Samples.Tests.UnitTestsControl[0]
	      Running test When_ExecuteScriptAsync_Has_No_Result()
	dbug: Uno.UI.Runtime.Skia.MacOS.MacOSNativeWebView[0]
	      LoadHtmlString: <html><body><script>function testMe(){ }</script><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>
	build/test-scripts/macos-skia-runtime-tests.sh: line 31: 70322 Segmentation fault: 11  dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$TEST_RESULTS_FILE

and as the .NET 11 bump updates `$(macOSVMImage)` to be macos-26 --
beecause only macos-26 has Xcode 26.5, which .NET 11 P5 requires --
for awhile it looked like this might be a .NET 11 issue.

PR #23622 verified that this was in fact a macos-26 issue, unrelated
to .NET 11.

Update `.azure-devops-tests-macos-skia.yml` to run the
**Tests - Desktop Skia MacOS** stage on $(vmMacImageTest) (macos-14)
instead of $(macOSVMImage) (macos-26).  This allows the tests to run
without crashing on CI.

*Note*: we are unable to locally reproduce the crash, though it *may*
be addressed by #23642.

Additionally, update `macos-skia-runtime-tests.sh` to explicitly log
the ABI of the machine running the tests, as `macos-26` means different
things between [GitHub Actions][0] (arm64!)

> | **Image**       | **Architecture**  | **YAML Label** |
> | --------------- | ----------------- |----------------|
> | macOS 26 Arm64  | arm64             | `macos-26` or `macos-26-xlarge` |

and [Azure DevOps][1] (x64!).

> **macOS images updates**
>
> * The macOS 26 (Intel) Azure Pipelines hosted agent image is in public preview.
> * …
> * The macOS 15 Sequoia ARM64 limited public preview has been paused.

(As far as @jonpryor can tell, Azure DevOps currently provides *no*
arm64 build agents…)

[0]: https://github.com/actions/runner-images/tree/f84258ba81f6e9f1edfaf7a83da4727921e85790#available-images
[1]: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=macos-images%2Cyaml#macos-images-updates
@ajpinedam
ajpinedam merged commit 970238d into unoplatform:master Jul 6, 2026
47 checks passed
@jonpryor jonpryor mentioned this pull request Jul 6, 2026
5 tasks
jonpryor added a commit that referenced this pull request Jul 7, 2026
Context: #23622
Context: #23642

**Tests - Desktop Skia macOS > Runtime Tests > Run macOS Runtime Tests**
regularly crashes on CI *when using macos-26*:

	info: Uno.UI.Samples.Tests.UnitTestsControl[0]
	      Running test When_ExecuteScriptAsync_Has_No_Result()
	dbug: Uno.UI.Runtime.Skia.MacOS.MacOSNativeWebView[0]
	      LoadHtmlString: <html><body><script>function testMe(){ }</script><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>
	build/test-scripts/macos-skia-runtime-tests.sh: line 31: 70322 Segmentation fault: 11  dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$TEST_RESULTS_FILE

and as the .NET 11 bump updates `$(macOSVMImage)` to be macos-26 --
beecause only macos-26 has Xcode 26.5, which .NET 11 P5 requires --
for awhile it looked like this might be a .NET 11 issue.

PR #23622 verified that this was in fact a macos-26 issue, unrelated
to .NET 11.

Update `.azure-devops-tests-macos-skia.yml` to run the
**Tests - Desktop Skia MacOS** stage on $(vmMacImageTest) (macos-14)
instead of $(macOSVMImage) (macos-26).  This allows the tests to run
without crashing on CI.

*Note*: we are unable to locally reproduce the crash, though it *may*
be addressed by #23642.

Additionally, update `macos-skia-runtime-tests.sh` to explicitly log
the ABI of the machine running the tests, as `macos-26` means different
things between [GitHub Actions][0] (arm64!)

> | **Image**       | **Architecture**  | **YAML Label** |
> | --------------- | ----------------- |----------------|
> | macOS 26 Arm64  | arm64             | `macos-26` or `macos-26-xlarge` |

and [Azure DevOps][1] (x64!).

> **macOS images updates**
>
> * The macOS 26 (Intel) Azure Pipelines hosted agent image is in public preview.
> * …
> * The macOS 15 Sequoia ARM64 limited public preview has been paused.

(As far as @jonpryor can tell, Azure DevOps currently provides *no*
arm64 build agents…)

[0]: https://github.com/actions/runner-images/tree/f84258ba81f6e9f1edfaf7a83da4727921e85790#available-images
[1]: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=macos-images%2Cyaml#macos-images-updates
jonpryor added a commit that referenced this pull request Jul 8, 2026
Context: #23622
Context: #23642

**Tests - Desktop Skia macOS > Runtime Tests > Run macOS Runtime Tests**
regularly crashes on CI *when using macos-26*:

	info: Uno.UI.Samples.Tests.UnitTestsControl[0]
	      Running test When_ExecuteScriptAsync_Has_No_Result()
	dbug: Uno.UI.Runtime.Skia.MacOS.MacOSNativeWebView[0]
	      LoadHtmlString: <html><body><script>function testMe(){ }</script><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>
	build/test-scripts/macos-skia-runtime-tests.sh: line 31: 70322 Segmentation fault: 11  dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$TEST_RESULTS_FILE

and as the .NET 11 bump updates `$(macOSVMImage)` to be macos-26 --
beecause only macos-26 has Xcode 26.5, which .NET 11 P5 requires --
for awhile it looked like this might be a .NET 11 issue.

PR #23622 verified that this was in fact a macos-26 issue, unrelated
to .NET 11.

Update `.azure-devops-tests-macos-skia.yml` to run the
**Tests - Desktop Skia MacOS** stage on $(vmMacImageTest) (macos-14)
instead of $(macOSVMImage) (macos-26).  This allows the tests to run
without crashing on CI.

*Note*: we are unable to locally reproduce the crash, though it *may*
be addressed by #23642.

Additionally, update `macos-skia-runtime-tests.sh` to explicitly log
the ABI of the machine running the tests, as `macos-26` means different
things between [GitHub Actions][0] (arm64!)

> | **Image**       | **Architecture**  | **YAML Label** |
> | --------------- | ----------------- |----------------|
> | macOS 26 Arm64  | arm64             | `macos-26` or `macos-26-xlarge` |

and [Azure DevOps][1] (x64!).

> **macOS images updates**
>
> * The macOS 26 (Intel) Azure Pipelines hosted agent image is in public preview.
> * …
> * The macOS 15 Sequoia ARM64 limited public preview has been paused.

(As far as @jonpryor can tell, Azure DevOps currently provides *no*
arm64 build agents…)

[0]: https://github.com/actions/runner-images/tree/f84258ba81f6e9f1edfaf7a83da4727921e85790#available-images
[1]: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=macos-images%2Cyaml#macos-images-updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants