Summary
HybridWebViewHandler.SchemeHandler and WebViewScriptMessageHandler members carry [RequiresUnreferencedCode] annotations that cause fatal IL2026 trim analysis errors (NETSDK1144) when building MAUI apps with TrimMode=full or AOT on iOS. This breaks the integration test legs that exercise trimmed and AOT builds.
Build Information
- Pipeline: maui-pr (ID 302)
- Build: 1446270 (latest)
- Branch: net11.0
- First seen: 2026-05-19 (build 1426532)
- Occurrences: 6+ in last 10 builds (every build in the window)
Affected Legs
RunOniOS_MauiRelease ARM64 — iOS ARM64
RunOniOS_MauiReleaseTrimFull ARM64 — iOS ARM64, TrimMode=full
RunOniOS_MauiReleaseTrimFull_CoreCLR ARM64 — iOS ARM64 CoreCLR, TrimMode=full
AOT macOS — macOS AOT
Error Message
ILLink : Trim analysis error IL2026: <Module>..cctor(): Using member
'Microsoft.Maui.Handlers.HybridWebViewHandler.SchemeHandler.StopUrlSchemeTask(WKWebView, IWKUrlSchemeTask)'
which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
HybridWebView uses dynamic System.Text.Json serialization features.
ILLink : Trim analysis error IL2026: <Module>..cctor(): Using member
'Microsoft.Maui.Handlers.HybridWebViewHandler.WebViewScriptMessageHandler.DidReceiveScriptMessage(WKUserContentController, WKScriptMessage)'
which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code.
error NETSDK1144: Optimizing assemblies for size failed.
Recommended Action
Investigate HybridWebViewHandler on iOS (files under src/Core/src/Handlers/HybridWebView/ and platform-specific iOS handlers). The inner types SchemeHandler and WebViewScriptMessageHandler are decorated with [RequiresUnreferencedCode] but the static constructor <Module>..cctor() references them unconditionally, making them visible to the trimmer at startup. Options:
- Replace dynamic JSON serialization with source-generated
System.Text.Json (preferred — removes the attribute entirely)
- Guard the static initializer with
[DynamicDependency] or restructure so the handler is only instantiated lazily when the trimmer cannot see the reference
This is a build-break class failure; no muting PR is appropriate — the handler must be fixed.
Generated by CI Failure Scanner (net11.0) · ● 58.1M · ◷
Summary
HybridWebViewHandler.SchemeHandlerandWebViewScriptMessageHandlermembers carry[RequiresUnreferencedCode]annotations that cause fatal IL2026 trim analysis errors (NETSDK1144) when building MAUI apps withTrimMode=fullor AOT on iOS. This breaks the integration test legs that exercise trimmed and AOT builds.Build Information
Affected Legs
RunOniOS_MauiRelease ARM64— iOS ARM64RunOniOS_MauiReleaseTrimFull ARM64— iOS ARM64, TrimMode=fullRunOniOS_MauiReleaseTrimFull_CoreCLR ARM64— iOS ARM64 CoreCLR, TrimMode=fullAOT macOS— macOS AOTError Message
Recommended Action
Investigate
HybridWebViewHandleron iOS (files undersrc/Core/src/Handlers/HybridWebView/and platform-specific iOS handlers). The inner typesSchemeHandlerandWebViewScriptMessageHandlerare decorated with[RequiresUnreferencedCode]but the static constructor<Module>..cctor()references them unconditionally, making them visible to the trimmer at startup. Options:System.Text.Json(preferred — removes the attribute entirely)[DynamicDependency]or restructure so the handler is only instantiated lazily when the trimmer cannot see the referenceThis is a build-break class failure; no muting PR is appropriate — the handler must be fixed.