Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

The blazor.webview.js from ASP.NET Core uses ES2022+ syntax (static{} blocks) not supported by older Android WebViews, causing:

Uncaught SyntaxError: Unexpected token '{'
source: https://0.0.0.1/_framework/blazor.webview.js (1)

This PR adds automatic fallback to an ES2019-compatible version on affected devices:

  • Embedded resource: Added blazor.webview.es2019.js (Android builds only)
  • Runtime detection: Check Build.VERSION.SdkInt < API 32 to identify older WebViews
  • Request interception: Serve ES2019 version when _framework/blazor.webview.js is requested on affected devices
  • Logging: Debug log when serving compatible version; warning if embedded resource missing

Related upstream issue: dotnet/aspnetcore#53699

Issues Fixed

Fixes #32860

Original prompt

This section details on the original issue you should resolve

<issue_title>BlazorWebView may have compatibility issues with Android 12.0 and earlier.</issue_title>
<issue_description>### Description

The official release of .NET 10 is an exciting milestone. I immediately tried to create a .NET 10 MAUI Blazor sample application to test it out. However, I was disappointed to find that the application did not function correctly in my testing environment.
To isolate the problem, I ran the sample app on multiple Android emulators with different OS versions. My tests revealed that the BlazorWebViewcomponent fails to work properly (manifesting as a white screen or content failing to load) on Android 11.0 (API 30)​ and Android 12.0 (API 31). In contrast, it functions as expected on Android 12.1 (API 32)​ and later versions.
I am unsure if this is caused by a specific configuration in my local environment or if it indicates a potential compatibility issue with .NET MAUI 10.0 itself. I would greatly appreciate any insight into the root cause of this behavior and guidance on how to resolve it.

Steps to Reproduce

1.Create a new project using the ".NET MAUI Blazor Hybrid App"​ template (the one that includes sample pages).

2.Build and deploy the application to an Android emulator running Android 12.0 (API 31)​ or an earlier version (e.g., Android 11.0 / API 30).

3.Launch the application on the emulator.

Expected Result:
The application loads correctly, displaying the sample Blazor content and UI without issues.

Actual Result:
The application fails to render the Blazor content properly.

Link to public reproduction project repository

No response

Version with bug

10.0.0

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12.0 and earlier

Did you find any workaround?

No, I have not found any workaround. The application only functions correctly on Android 12.1 (API 32) and above.

Relevant log output

11-25 15:29:57.296 I/chromium( 5949): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token '{'", source: https://0.0.0.1/_framework/blazor.webview.js (1)
11-25 15:29:57.362 I/chromium( 5949): [INFO:CONSOLE(2)] "Uncaught ReferenceError: Blazor is not defined", source: https://0.0.0.1/ (2)
11-25 15:29:58.569 D/EGL_emulation( 5949): app_time_stats: avg=146.35ms min=2.18ms max=1134.14ms count=9
11-25 15:30:02.257 D/ProfileInstaller( 5949): Installing profile for com.companyname.mauiapp1
```</issue_description>

<agent_instructions>I think some new syntax might be introduced in the blazor js file that is incompatible with older browsers. Can you check to see what it and fix it so that it works for both old and new browsers? Maybe also include online research, maybe this also happened on the Blazor product and not just Blazor Hybrid</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@jfversluis</author><body>
Looking at the output some JavaScript error, maybe something between those versions that Chromium has gotten/dropped support for some JavaScript thing? </body></comment_new>
</comments>

Custom agent used: issue-resolver
Specialized agent for investigating and resolving community-reported .NET MAUI issues through hands-on testing and implementation


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 30, 2025
Copilot AI and others added 2 commits November 30, 2025 16:20
On Android API < 32 (Android 12.0 and earlier), the default
blazor.webview.js uses ES2022+ syntax (like static{} blocks)
that is not supported by older WebView versions, causing
"Uncaught SyntaxError: Unexpected token '{'" errors.

This change:
- Adds an ES2019-compatible version of blazor.webview.js as
  an embedded resource (only for Android builds)
- Detects older Android versions at runtime
- Serves the ES2019 version instead of the default version
  on affected devices

Fixes #32860

Co-authored-by: jfversluis <[email protected]>
- Extract magic number 32 into named constant MinimumSdkVersionForES2022
- Add logging for ES2019 resource loading and fallback warning

Co-authored-by: jfversluis <[email protected]>
Copilot AI changed the title [WIP] Fix BlazorWebView compatibility issues with Android 12.0 and earlier Fix BlazorWebView compatibility with Android 12.0 and earlier Nov 30, 2025
Copilot AI requested a review from jfversluis November 30, 2025 16:29
Copilot finished work on behalf of jfversluis November 30, 2025 16:29
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.

BlazorWebView may have compatibility issues with Android 12.0 and earlier.

2 participants