Skip to content

[ci-scan-net11] HybridWebViewHandler IL2026 trim errors break iOS/AOT integration tests on net11.0 #35740

@github-actions

Description

@github-actions

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:

  1. Replace dynamic JSON serialization with source-generated System.Text.Json (preferred — removes the attribute entirely)
  2. 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 ·

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci-scan-net11CI scanner findings for net11.0

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions