dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.72k forks source link

Unexpected Syntax Error in blazor.webview.js on iOS lower than v17 in .NET 9 Pre7 #24278

Open mhrastegari opened 3 weeks ago

mhrastegari commented 3 weeks ago

Description

We're trying to update our projects and templates to the .NET. 9 preview 7 but in iOS version of our app on devices with OS versions lower than 17 not working!

Steps to Reproduce

  1. Create a new .NET MAUI Blazor app using .NET CLI
  2. Run it on iOS versions lower than 17

Link to public reproduction project repository

https://github.com/mhrastegari/BlazorIssueWithOldIosVersions

Version with bug

9.0.0-preview.7.24407.4

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.80 SR8

Affected platforms

iOS

Affected platform versions

Tested on iOS 16 & iOS 15

Did you find any workaround?

No

Relevant log output

SyntaxError: Unexpected token '{'
If (anonymous function) — blazor.webview.js:1
ReferenceError: Can't find variable: Blazor
Global Code - user-script:1:15

Screenshots

Screenshot 2024-08-16 at 16 53 11

Working on iOS 17 but not 16: Screenshot 2024-08-16 at 16 59 11

Eilon commented 3 weeks ago

Thanks for the report we will investigate!

Eilon commented 3 weeks ago

@javiercn / @SteveSandersonMS / @MackinnonBuck - thoughts on this?

We've had issues in the past where a change in Blazor caused an issue on older web views:

I'm not sure if this is a case of:

  1. Blazor maybe generally has an issue on these versions of iOS?
  2. Blazor's WebView JS code has an issue specifically on these versions of iOS?

I know in general Blazor supports only the 'latest browser' but this scenario might be a bit different because it's probably the latest WebKit/Gecko/Safari for that OS?

Eilon commented 3 weeks ago

I tried .NET 9 Preview 7 with a Blazor Web app and that works fine on iOS 16.4.

MackinnonBuck commented 3 weeks ago

Hm, this probably needs investigating.

@mhrastegari, do the dev tools point to a specific location in blazor.webview.js failing? Also, are you able to see the content returned by the browser's request to blazor.webview.js? I'm wondering if either:

  1. The request to blazor.webview.js is returning something other than the actual script (e.g., JSON)
  2. We're using a JS feature not supported by older browsers
MackinnonBuck commented 3 weeks ago

We received a similar report of this in https://github.com/dotnet/aspnetcore/issues/57326

Eilon commented 3 weeks ago

@MackinnonBuck I'm trying to repro locally but it's taking a while to get my Mac set up for .NET 9 Preview 7.

The other report is interesting because it seems to imply it's an issue with all the Blazor JS files... I couldn't repro that in my quick test earlier.

MackinnonBuck commented 3 weeks ago

@Eilon Interesting. So it is probably an issue with the script itself then (not with fetching the script).

MackinnonBuck commented 3 weeks ago

Well, wait. I spoke to soon. The screenshot in that other issue shows blazor.webview.js. It might be that "blazor.web.js" in the issue title is a typo.

MackinnonBuck commented 3 weeks ago

So maybe the problem does only happen for blazor.webview.js.

ninachen03 commented 3 weeks ago

This issue has been verified using latest Visual Studio 17.12.0 Preview 1.0 (9.0.0-preview.7.24407.4). Can repro on iOS platform. works fine on 17.12.0 Preview 1.0 (8.0.80)