Skip to content

spanglerp/maui-blazor-ios-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

BlazorWebView iOS Bug Reproduction

Bug Description

BlazorWebView on iOS (.NET 10) starts Blazor successfully, but the RootComponent is never rendered into the DOM.

The #app element remains unchanged. This works correctly on Android with the same codebase.

Environment

  • .NET SDK: 10.0.100
  • Microsoft.Maui.Controls: 10.0.11
  • Microsoft.AspNetCore.Components.WebView.Maui: 10.0.11
  • Target: iOS 17.0+
  • Device: Physical iPhone
  • Build: Release with AOT

Steps to Reproduce

  1. Clone this repository
  2. Build for iOS:
    dotnet publish BugRepro/BugRepro.csproj -f net10.0-ios -c Release
  3. Install the .ipa on an iOS device
  4. Observe that:
    • The app starts
    • The HTML loads (you can see the loading indicator)
    • Blazor starts (confirmed via JavaScript - Blazor.start() throws "Blazor has already started")
    • But the RootComponent is NEVER rendered

Expected Behavior

The Blazor component registered in MainPage.xaml should render into the #app element, showing the Counter page.

Actual Behavior

  • HTML loads correctly ✓
  • JavaScript executes ✓
  • blazor.webview.js loads ✓
  • Blazor starts automatically ✓
  • Error message appears: "An unhandled error has occurred. Reload" ✗

The app shows "Loading..." briefly, then displays the error message. The Blazor components never render.

Debugging Attempted

We confirmed via JavaScript that:

// This throws "Blazor has already started" - proving Blazor IS running
Blazor.start().catch(err => console.log(err.message));

Workarounds Attempted (all failed)

  • Disabled AOT (PublishAot=false, UseInterpreter=true) - same issue
  • Disabled trimming (MtouchLink=None) - app crashes on startup
  • Added TrimmerRootAssembly for the main assembly - same issue
  • Programmatically added RootComponent in MainPage.xaml.cs - same issue
  • Simplified Routes.razor to just <h1>Test</h1> (no code) - same issue
  • Removed all external CSS/JS references - same issue
  • Updated to MAUI 10.0.11 - same issue

Platform Comparison

Platform Status
Android ✅ Works
iOS ❌ Broken

Related Warnings

Build output shows many trim warnings that might be related:

Trim analysis warning IL2111: Method 'Microsoft.AspNetCore.Components.Routing.Router.NotFoundPage.set'
with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection.
Trimmer can't guarantee availability of the requirements of the method.

Suggested Fix

The issue appears to be that the BlazorWebView's RootComponent registration is not being properly communicated to the Blazor runtime on iOS, even though Blazor itself starts correctly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors