Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] .NET 9 generated JS uses high version syntax leading to compatibility issues #59090

Open
1 task done
capdiem opened this issue Nov 21, 2024 · 6 comments
Open
1 task done
Assignees
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Milestone

Comments

@capdiem
Copy link

capdiem commented Nov 21, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The blazor.*.js files generated by .NET 9 utilize the static initialization block feature introduced in ES2022. This usage causes compatibility issues on lower-end devices and older browsers.
You can find instances of this issue by searching for static{ in the generated files.

static{this.nextEventDelegatorId=0}

related issue: dotnet/maui#24278 dotnet/maui#25862

Expected Behavior

Regenerate using ES2019(.NET 8) as the target, just like before.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

net9.0

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Nov 21, 2024
@javiercn javiercn modified the milestones: 9.0.x, .NET 10 Planning Nov 21, 2024
@javiercn javiercn added this to the Backlog milestone Nov 21, 2024
@danroth27
Copy link
Member

Our official support policy is that we only support the latest browser versions. Since most users automatically update their browser, we find this isn't generally an issue. When setting up test devices, we recommend similarly updating the browser/webview to emulate this common user behavior.

@danroth27 danroth27 added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Nov 21, 2024
@capdiem
Copy link
Author

capdiem commented Nov 22, 2024

@danroth27 While it's true that most users automatically update their browsers, not all users are accustomed to doing so. Setting the tsconfig target to a version as high as ES2022 can lead to compatibility issues, especially considering that .NET 8 targets ES2019.

For a framework with such a large user base, backward compatibility is crucial. Many popular JavaScript libraries set their minimum support to ES2015, and I believe that for Blazor, targeting ES2019 would be a more reasonable approach. This change would help prevent any breaking updates when upgrading to .NET 9.

Thank you for your reply!

@nieuwveen
Copy link

The majority of our user base does not have access to the latest mobile devices.
Now use a custom version of blazor.web.js that ensures greater compatibility.
Create your own custom version of blazor.web.js, with Babel.js

@danroth27
Copy link
Member

The majority of our user base does not have access to the latest mobile devices.

@nieuwveen That's certainly true, but even older devices can still get browser updates. So even if the user has an older phone, often they will still have an updated browser that can run Blazor apps. Most often we hear about users hitting problems testing with emulated devices for older Android versions that haven't been similarly updated. But if you're instead hitting problems with users using your deployed Blazor app on an actual device, please do let us know!

Now use a custom version of blazor.web.js that ensures greater compatibility.

This is certainly an option for those who are able to take on this additional responsibility. Obviously, we can't make any claims how well this will work because it's not a scenario we test and directly support.

@capdiem
Copy link
Author

capdiem commented Nov 23, 2024

@danroth27 It's not just the emulator, we have physical testing devices for various Android versions, and we encounter these issues on devices running below Android 12, as I have already pointed out. While I can certainly clone this project and manually compile the blazor.*.js targeting ES2018, that is not a solution that works for everyone.

Related issues: #57326 dotnet/maui#24278

@nieuwveen
Copy link

@danroth27 You are right that older phones still receive updates, but not every user installs them. Sometimes there isn’t enough space to install them, or users may not know about the updates.
Perhaps we need something to show a message to the users that their device needs an update.
We’ve received multiple reports of iPhones that have problems, after installing the latest IOS the problem is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants