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

Unexpected Syntax Error in blazor.web.js on iOS Versions Below 17 in .NET 9 Preview 7 #57326

Open
ysmoradi opened this issue Aug 14, 2024 · 27 comments
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.

Comments

@ysmoradi
Copy link

ysmoradi commented Aug 14, 2024

Before diving into the details, could you please confirm if the blazor.web.js in .NET 9 Preview 7 is intended to support only iOS 17 and above? The same script works seamlessly on Android 7 (API level 25).

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Aug 14, 2024
@ysmoradi ysmoradi changed the title blazor.web.js unexpected syntax error on iOS below 17 blazor.web.js unexpected syntax error on iOS below 17 on .NET 9 preview 7 Aug 14, 2024
@ysmoradi ysmoradi changed the title blazor.web.js unexpected syntax error on iOS below 17 on .NET 9 preview 7 Unexpected Syntax Error in blazor.web.js on iOS Versions Below 17 in .NET 9 Preview 7 Aug 14, 2024
@javiercn
Copy link
Member

javiercn commented Aug 14, 2024

@ysmoradi thanks for contacting us.

Our support official support policy is detailed here.

Can you provide more details on the error you are seeing?

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Aug 14, 2024
@ysmoradi
Copy link
Author

ysmoradi commented Aug 15, 2024

Due the fact that the js file is minified, I couldn't find the problematic part
image
But as far as I tested, the same issue exists with blazor.webview.js and blazor.webassembly.js as well.

Reproducing this is not that hard, simply create a new blazor project of anykind (webassembly standalone, blazor hybrid or blazor webapp) and try open it in iOS 16 or iOS 15 (You might need to disable SIMD as well)

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Aug 15, 2024
@MackinnonBuck MackinnonBuck closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2024
@ysmoradi
Copy link
Author

@MackinnonBuck Could you please clarify why this issue is closes?

@ysmoradi
Copy link
Author

@Eilon
Copy link
Member

Eilon commented Aug 16, 2024

@ysmoradi do you have specific repro steps for the problem you had? I created a new .NET 9 Preview 7 app using dotnet new blazor -o MyBlazorTest, then did a dotnet run for it, and access the site from an iPhone 14 Simulator running iOS 16.4, and the app loaded fine and I could click everything.

@MackinnonBuck
Copy link
Member

@ysmoradi, could you also clarify whether you were able to reproduce the problem with a Blazor Web App (blazor.web.js, as the issue title suggests)? Or does this only happen in blazor.webview.js?

@Eilon
Copy link
Member

Eilon commented Aug 16, 2024

The repro comment suggested it was all of them:

Reproducing this is not that hard, simply create a new blazor project of anykind (webassembly standalone, blazor hybrid or blazor webapp) and try open it in iOS 16 or iOS 15 (You might need to disable SIMD as well)

But I'd like to confirm this with screenshots or if we can repro it ourselves.

@Eilon
Copy link
Member

Eilon commented Aug 16, 2024

I tried .NET 9 Preview 7 in the iOS Simulator running iOS 16.4 and BlazorWebView loaded fine:

image

So there must be something about these repro steps we're not matching...

@ysmoradi
Copy link
Author

ysmoradi commented Aug 17, 2024

Thanks for your efforts
on iOS 16.4, it works

image
but even on iOS 16.3, it doesn't work

image

I'm going to check other versions as well.

@ysmoradi
Copy link
Author

image

@ysmoradi
Copy link
Author

ysmoradi commented Aug 17, 2024

The issue exists for iOS 14, 15 and 16.3, but it worked for me on iOS 16.4, 17 and 18 (beta)

@Eilon
Copy link
Member

Eilon commented Aug 17, 2024

Ah thank you, I'll try to replicate on those versions as well.

@Eilon
Copy link
Member

Eilon commented Aug 17, 2024

Alright confirmed repro on iOS 16.2 Simulator with a Blazor Web app. And just to make sure it's not a general issue with iOS 16.2, I tried a Blazor .NET 8.0 web app and that worked fine.

@MackinnonBuck - if someone can provide me with an unminified blazor.web.js I can try to use that instead of the default _framework/blazor.web.js to see if it's the minification that's breaking the file, or something else.

@javiercn
Copy link
Member

@Eilon are we talking about blazor.web.js or blazor.webview.js.

Note that in any case older versions are not officially supported as per https://learn.microsoft.com/en-us/aspnet/core/blazor/supported-platforms?view=aspnetcore-8.0

Given the type of error we are seeing, it's probably that the bundle depends on a newer JS syntax not supported in those Safari versions.

One option in that situation would be to transpile the bundle to a lower JS subset, but that's not something we will do.

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Aug 17, 2024
@msynk
Copy link

msynk commented Aug 17, 2024

first of all, thank you for bringing up this issue and discussing it in detail.
secondly, by the nature of the error thrown and shown here, it is obvious that something is wrong with the supported version of the ECMA script in those older versions of iOS (and Safari).
so how this is happening even though at least in the supported platforms of the MAUI Blazor, iOS 14 is mentioned as the minimum platform requirement:
https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms?view=net-maui-8.0
image

the main question here is, are you going to stop supporting those older versions of iOS in the future versions of .NET and Blazor? (so we can also drop the support in our products)

https://gs.statcounter.com/ios-version-market-share/
image

thanks in advance.

@ysmoradi
Copy link
Author

Note that this issue happens in blazor.web, blazor.webview.js and blazor.webassembly.js

@msynk
Copy link

msynk commented Aug 17, 2024

another note:
Preview 7 is not the first version that this problem happens in. I believe we have seen this issue for the last few previews of the .NET 9.

@ysmoradi
Copy link
Author

😒

@MackinnonBuck MackinnonBuck removed ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved labels Aug 19, 2024
@MackinnonBuck MackinnonBuck reopened this Aug 19, 2024
@javiercn
Copy link
Member

javiercn commented Aug 19, 2024

first of all, thank you for bringing up this issue and discussing it in detail. secondly, by the nature of the error thrown and shown here, it is obvious that something is wrong with the supported version of the ECMA script in those older versions of iOS (and Safari). so how this is happening even though at least in the supported platforms of the MAUI Blazor, iOS 14 is mentioned as the minimum platform requirement: https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms?view=net-maui-8.0 image

the main question here is, are you going to stop supporting those older versions of iOS in the future versions of .NET and Blazor? (so we can also drop the support in our products)

https://gs.statcounter.com/ios-version-market-share/ image

thanks in advance.

For what is worth, apple provides their own numbers on marketshare https://developer.apple.com/support/app-store/

image

@msynk
Copy link

msynk commented Aug 19, 2024

Thanks for your input.

It seems there's been a misunderstanding, my main point was to show that most of the users are using the latest versions of iOS, but still around 10-20% are using those old versions that have the problem discussed in this issue.

So based on these data, is Blazor not going to support those older versions of iOS anymore?
We want to make sure that it's not an issue of the Blazor and that it is an intentional change, so we can also drop the support.

@Andrzej-W
Copy link

It is important that 32% of iPads have system older than 17.x. Now ask yourself a simple question: do you want to reduce your income by 32% ? I think you're not ready for this unless your uncle is Elon Musk.

I understand that support for WebAssembly in individual browsers is evolving rapidly and we cannot expect the latest version of dotnet to work properly in a browser from a few years ago. On the other hand, Blazor Server and Hybrid do not require support for WebAssembly. It is possible that a bug like this one can be corrected very quickly.

In my opinion your support policy for Blazor Server and Hybrid should be changed, at least for Apple devices. On Windows or Android you can always have the newest and greatest browser. Unfortunately this is not the case on Apple devices where Safari is part of the operating system.

Here is a perfect solution for Blazor web application configured for Auto mode:

  • Download some JS code and test the browser capabilities.
  • If all the features required for WebAssembly are NOT available don't load WASM files and force Server mode.
  • Otherwise start in Server mode and download WASM files in the background.
  • Add an option to switch from Server to WASM upon page navigation.
  • Add an option to switch from Server to WASM if page is idle for the specified time. Not every page can be easily switched due to complex state - add an attribute to mark pages as switchable.

@javiercn
Copy link
Member

@Andrzej-W I don't want to start a discussion on this issue, however, I will provide some comments to not leave you without answers.

There are other factors to take into account when making these decisions like testing etc. that influence the cost. It's always a trade-off between cost/benefit.

It is important that 32% of iPads have system older than 17.x. Now ask yourself a simple question: do you want to reduce your income by 32% ?

As the discussion above points out this is not the case. For that to be the case:

  • All your users would have to be ios/ipad users.
  • You would have a significant amount of those users visiting you from older versions of the OS, which is unlikely to be the case, simply because devices that aren't up to date are usually not used frequently.
  • You would be monetizing/converting all your users.

Even in that case, the LTS works for 16 and 17, which accounts for 97% devices released in the last four years. .NET 9.0 works from 16.4 and above, which also sum up to 95% (I'm giving 2% to users below 16.4), which is a very different number than the one you threw out.

In my opinion your support policy for Blazor Server and Hybrid should be changed, at least for Apple devices. On Windows or Android, you can always have the newest and greatest browser. Unfortunately, this is not the case on Apple devices where Safari is part of the operating system.

Browsers have significantly changed this model over the past years. Chrome doesn't offer support for older versions and updates automatically. Edge follows a similar policy where the maximum support is for 8 Weeks after a new version is available.

Safari, while not updating that regularly, still provides several updates across the release cycle of a given iOS version. A given iOS version stops receiving features the moment a new version of the OS is out and only receives security updates.

We can go and chase the long tail of older browsers, but that has a non-trivial cost in terms of development, testing and maintenance that needs to be put against other work, like new features, bug fixes and improvements. It's something that browser vendors have given up on themselves and switch everybody to a "keep your browser current" policy. What's even more important is that the direction of the trend is for this usage to naturally decline over time (and in many cases quite fast).

With that in mind, we essentially support what is supported by Browser Vendors on a given release, we don't go out of our way to make older versions unsupported, but we don't focus on supporting versions that aren't even supported by the browser vendor themselves, unless there's a significant reason for it.

Even in the cases where we don't support a specific OS/Browser version, JavaScript wise, nothing precludes you from grabbing the sources and compiling your own version with support for older versions via lowering the JS to older versions and including pollyfills for missing features, but it's not something that we are going to support, because it has a non-trivial cost and most people aren't going to need it.

Here is a perfect solution for Blazor web application configured for Auto mode:

  • Download some JS code and test the browser capabilities.
  • If all the features required for WebAssembly are NOT available don't load WASM files and force Server mode.
  • Otherwise start in Server mode and download WASM files in the background.
  • Add an option to switch from Server to WASM upon page navigation.
  • Add an option to switch from Server to WASM if page is idle for the specified time. Not every page can be easily switched due to complex state - add an attribute to mark pages as switchable.

If you have a concrete improvement, file a separate issue for us to track it and discuss it. For now, what I would say is that this has a very nontrivial cost, introduces a ton of complexity, and it's not clear to me whether it's worth doing all this work and introducing this complexity to support older versions that represent a small percentage of the total user base that is only going to shrink over time.

@javiercn
Copy link
Member

The team will revisit this, and we will provide an update once we've discussed this.

@javiercn javiercn added this to the .NET 10 Planning milestone Aug 21, 2024
@msynk
Copy link

msynk commented Aug 21, 2024

So I assume Blazor is not going to support the older versions of the iOS/Safari anymore, even though we have this in the documents:
https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms?view=net-maui-9.0
image

I hope this section of the doc gets updated for the .NET 9 😊

@Andrzej-W
Copy link

@javiercn I understand all your arguments and honestly I would like to live in an ideal world where only the latest devices/browsers need to be supported.

The user base may vary by country and industry. I talked about iPads and 32% income reduction because my users are salespeople working in the field. Mobile phones are to small for them, cheap plastic tablets are not durable - they usually use iPads.

I have found information that iPad released in March 2018 and iPad Pro released in June 2017 are upgradable to iPadOS 17.x. The same is true for iPhone XS and XR released in September 2018.

iPhone 8 and X (2017) are upgradeable to iOS 16.7.7.

iPhone 7 released in 2016 is upgradeable to iOS 15.8.1 only.

it's not clear to me whether it's worth doing all this work and introducing this complexity to support older versions that represent a small percentage of the total user base that is only going to shrink over time.

You are probably right - there are many more important problems to solve.

One minor update to Blazor JavaScript code would be useful. Detect Blazor compatibility with the browser and display message (which can be easily translated into different languages) that browser is to old and have to be upgraded.

@jlbeard84
Copy link

For us, this makes .NET 9 problematic, and it makes me wonder how we deal with it considering the official policy is that .NET 8 MAUI leaves support in May 2025. Considering we need to support older devices, for much of the same reasoning that @Andrzej-W gave, we need to have some sort of workaround or resolution for this or we'll be stuck on .NET 8 for the foreseeable future.

@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. and removed question labels Sep 23, 2024
@capdiem
Copy link

capdiem commented Nov 23, 2024

Just need to revert to pointing to ES2019, just like with .NET 8.

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 bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

9 participants