dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.48k stars 10.03k forks source link

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

Open ysmoradi opened 3 months ago

ysmoradi commented 3 months ago

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).

javiercn commented 3 months ago

@ysmoradi thanks for contacting us.

Our support official support policy is detailed here.

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

ysmoradi commented 3 months ago

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)

ysmoradi commented 3 months ago

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

ysmoradi commented 3 months ago

https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms image

Eilon commented 2 months ago

@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 commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

image

ysmoradi commented 2 months ago

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

Eilon commented 2 months ago

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

Eilon commented 2 months ago

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 commented 2 months ago

@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.

msynk commented 2 months ago

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 commented 2 months ago

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

msynk commented 2 months ago

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 commented 2 months ago

😒

javiercn commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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:

javiercn commented 2 months ago

@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:

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 commented 2 months ago

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

msynk commented 2 months ago

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 commented 2 months ago

@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 commented 1 month ago

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.