Skip to content

fix(sdk): Hide unused WebView2Aot references from ILLink - #26696

Open
ramezgerges wants to merge 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/webview2aot-illink-references
Open

ramezgerges wants to merge 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/webview2aot-illink-references

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24618

PR Type:

🐞 Bugfix

What changed? 🚀

A trimmed desktop publish still hangs at "Optimizing assemblies for size" on Uno.Sdk 7.0.22, which includes #25862, for an app that never uses a WebView (report).

Why #25862 wasn't enough. It leaves the WebView2Aot/DirectNAot runtime assets out of the app. Their compile assets stay in ReferencePath, because Uno.UI.Runtime.Win32 compiles against them, and _RunILLink passes every ReferencePath item to ILLink as -reference … --action skip. ILLink still loads them and walks the 29-deep ICoreWebView2_* chain for the WebView2 types the host touches, which is the walk from dotnet/runtime#136766.

The 18 s result in #25862 came from its first revision, which also removed the compile assets. A later revision kept them, so a head that uses DirectN itself still compiles, and the trimmed publish wasn't timed again. On the same machine today, the first revision publishes the original repro in 16 s and the merged one is still in ILLink after 10 minutes.

Fix. Two targets next to _UnoRemoveUnusedWebView2Aot:

Compile references are untouched. Nothing changes when the app uses a WebView, when DirectN has another owner (only WebView2Aot is hidden then), or with UnoIncludeWebView2Aot=true.

Validation. Uno.Sdk 7.0.22 repacked as 7.0.22-local.1 with only this change applied to its Uno.SingleProject.Desktop.targets, on a fresh unoapp desktop head (UnoFeatures = Skia), dotnet publish -f net10.0-desktop -r win-x64 --self-contained -p:PublishTrimmed=true:

Case Stock 7.0.22 With this change
Trimmed publish, no WebView still in ILLink after 10 min, killed 18 s; no WebView2/DirectN shipped; app starts and renders
Trimmed publish, head referencing DirectNAot and using its types not run 38 s; only WebView2 hidden; DirectN.dll shipped; the head's DirectN code runs in the trimmed app
NativeAOT publish (PublishAot=true) 75 s builds; app starts. ILC's inputs are unchanged (neither run passes it WebView2/DirectN)

With TrimmerSingleWarn=false, the trimmed publishes report 26 IL2050 (Win32 UI Automation P/Invokes) and 2 IL2026 (macOS WebView JSON), the same ones #25862 recorded. None mention WebView2, DirectN or an unresolved assembly.

Apps that use a WebView still need the ILLink fix (dotnet/runtime#136766) for a trimmed publish.

PR Checklist ✅

🤖 Generated with Claude Code

Leaving the WebView2Aot/DirectN assets out of the app did not stop a
trimmed publish from hanging: their compile assets stay in ReferencePath,
so ILLink still loads them and walks the WebView2 interface chains for the
types the Win32 host touches. They are now removed from ReferencePath for
the ILLink step only, and put back afterwards.

Fixes unoplatform#24618

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mergify

mergify Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@ramezgerges ramezgerges mentioned this pull request Nov 24, 2026
1 of 2 tasks
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trimmed Skia Desktop publish hangs

4 participants