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 WASM applications on net8.0 freeze on startup on iOS 18 RC (22A3354) when built with AOT #105893

Closed
zotanmew opened this issue Aug 2, 2024 · 29 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono os-browser Browser variant of arch-wasm
Milestone

Comments

@zotanmew
Copy link

zotanmew commented Aug 2, 2024

Description

The Blazor WASM example project, when built against net8.0 with RunAOTCompilation, freezes on startup on iOS 18 Beta 2/3/4 (22A5297f/22A5307f/22A5316j). The same issue does not occur when building against net9.0 (-preview6), or when using iOS 18.0 beta 1 (22A5282m), iOS 17.5 or 16.4. It also doesn't affect Safari Technology Preview for macOS. I've not been able to test it on macOS Beta, as I don't have access to a Mac running the beta.

Reproduction Steps

  1. dotnet new blazorwasm
  2. Run dotnet publish -p:RunAOTCompilation=true
  3. Run python3 -m http.server 9000 -b 0.0.0.0 -d bin/Release/net8.0/publish/wwwroot
  4. Open :9000 on an iOS 18 Beta 4 device (real hardware or xCode Simulator)

Expected behavior

The application starts normally

Actual behavior

The application freezes on startup, with the loading indicator stuck at 100%.

The following logs are printed to console:

[Warning] MONO_WASM: Exception marshalling result of JS promise to CS:  (dotnet.runtime.8.0.7.e9r13h23hd.js, line 3)
RuntimeError: Out of bounds memory access (evaluating 'St.mono_wasm_write_managed_pointer_unsafe(t,e)')
<?>.wasm-function[35357]
set — dotnet.runtime.8.0.7.e9r13h23hd.js:3:7696
release — dotnet.runtime.8.0.7.e9r13h23hd.js:3:8465
kr — dotnet.runtime.8.0.7.e9r13h23hd.js:3:35559
(anonymous function) — dotnet.runtime.8.0.7.e9r13h23hd.js:3:209727
(anonymous function) — dotnet.runtime.8.0.7.e9r13h23hd.js:3:42386

[Error] [object WebAssembly.Exception]
	<?>.wasm-function[35231]
	<?>.wasm-function[28152]
	<?>.wasm-function[27916]
	<?>.wasm-function[30579]
	<?>.wasm-function[29954]
	<?>.wasm-function[29960]
	<?>.wasm-function[29984]
	<?>.wasm-function[35328]
	kr (dotnet.runtime.8.0.7.e9r13h23hd.js:3:35395)
	(anonymous function) (dotnet.runtime.8.0.7.e9r13h23hd.js:3:209274)
	Mr (dotnet.runtime.8.0.7.e9r13h23hd.js:3:37421)
	Pr (dotnet.runtime.8.0.7.e9r13h23hd.js:3:37561)

Regression?

No response

Known Workarounds

No response

Configuration

Tested on the following configuration (net8.0), but the issue also occurs when building on Arch Linux, using SDK 8.0.107 with runtime 8.0.7. Appears to work fine when built against net9.0 using the same configuration.

.NET SDK:
 Version:           9.0.100-preview.6.24328.19
 Commit:            ef4c241666
 Workload version:  9.0.100-manifests.21d7f649
 MSBuild version:   17.11.0-preview-24318-05+4a45d5633

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/9.0.100-preview.6.24328.19/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [wasm-tools]
   Installation Source: SDK 9.0.100-preview.6
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100-preview.6/microsoft.net.workload.mono.toolchain.current/9.0.0-preview.6.24327.7/WorkloadManifest.json
   Install Type:        FileBased

 [wasm-tools-net8]
   Installation Source: SDK 9.0.100-preview.6
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100-preview.6/microsoft.net.workload.mono.toolchain.net8/9.0.0-preview.6.24327.7/WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      9.0.0-preview.6.24327.7
  Architecture: arm64
  Commit:       static

.NET SDKs installed:
  8.0.303 [/usr/local/share/dotnet/sdk]
  9.0.100-preview.6.24328.19 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-preview.6.24328.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-preview.6.24327.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 2, 2024
@zotanmew zotanmew changed the title Blazor WASM with AOT enabled freezes on startup on iOS 18 Beta 4 (22A5316j) Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 4 (22A5316j) when built with AOT Aug 2, 2024
@zotanmew
Copy link
Author

zotanmew commented Aug 2, 2024

Some more data, possibly related, but I'm not entirely sure:

  • On iOS 16.4 (Simulator), and iOS 16.6 (real device), with NativeAOT & SIMD is enabled, my application crashes on startup with Error: AggregateException_ctor_DefaultMessage (Arg_IndexOutOfRangeException). I've not been able to reproduce this crash with SIMD disabled, or with iOS 17.5 (Simulator) and iOS 18.0 Beta 4 (Simulator & real device). Blazor WASM applications crash on startup on iOS 16.4-16.6 when built with AOT & referencing certain dependencies #105912
  • When testing my application (instead of the minimally reproducible example mentioned above) I can reproduce the error mentioned in this issue in the Safari Technology Preview.
  • When using .NET 9, when testing my application (instead of the minimally reproducible example mentioned above), I get a different crash (Out of bounds memory access in o.mono_background_exec) both in Safari iOS 18.0 beta 4 (simulator & real device), as well as the Safari TP. Interestingly, the error occurs only on some pages of the application. I cannot test this issue against .NET 9, because the above issue occurs with every test pass. It's therefore possible, but not certain, that this issue affects .NET 8.

I have sadly not managed to produce any self-contained examples of these issues, which is why I haven't created separate issues for them.

The application in question is open source, so I can write reproduction instructions should it become relevant. I'd much rather trace the issue & provide a minimally reproducible example though, as the application is quite large.

My gut tells me that all the iOS 18 / Safari TP bugs are related, but the iOS 16 SIMD bug is separate. This is just a hunch, though.

@zotanmew zotanmew changed the title Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 4 (22A5316j) when built with AOT Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 2/3/4 (22A5297f/22A5307f/22A5316j) when built with AOT Aug 3, 2024
@zotanmew
Copy link
Author

zotanmew commented Aug 3, 2024

Traced the SIMD issue, see link in the above comment. Also traced this issue to specifically affect iOS 18 beta 2 and newer, beta 1 appears to be unaffected.

@zotanmew
Copy link
Author

zotanmew commented Aug 3, 2024

Since this may be an iOS bug, I filed a radar with Apple (FB14644808) containing a link to this issue.

@lambdageek lambdageek added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Aug 5, 2024
@lewing lewing added this to the 9.0.0 milestone Aug 5, 2024
@ilonatommy ilonatommy removed the untriaged New issue has not been triaged by the area owner label Aug 6, 2024
@zotanmew
Copy link
Author

zotanmew commented Aug 6, 2024

On iOS 18.0 beta 5 (22A5326f), this crash seems to only happen sometimes. As a simulator runtime for that build is not yet available, this is from testing on a physical device. When it does freeze/crash, the logs are the same as in the original issue.

@mkhamoyan mkhamoyan modified the milestones: 9.0.0, 10.0.0 Aug 12, 2024
@zotanmew
Copy link
Author

Beta 6 (22A5338b) has the same behavior as Beta 5.

@blanchardglen
Copy link

This is affecting our Blazor WASM application as well. Unfortunately there are additional compilation bugs with .net 9 that prevent us testing if it is fixed there.
With iOS 18 due within a few weeks we are nervous that potentially half of our userbase will lose access to our application.

@zotanmew
Copy link
Author

zotanmew commented Sep 6, 2024

Beta 8 (22A5350a) has the same behavior as Beta 6.

@zotanmew zotanmew changed the title Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 2/3/4 (22A5297f/22A5307f/22A5316j) when built with AOT Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 2-8 (22A5297f-22A5350a) when built with AOT Sep 6, 2024
@zotanmew zotanmew changed the title Blazor WASM applications on net8.0 freeze on startup on iOS 18 Beta 2-8 (22A5297f-22A5350a) when built with AOT Blazor WASM applications on net8.0 freeze on startup on iOS 18 RC (22A3354) when built with AOT Sep 10, 2024
@zotanmew
Copy link
Author

Still affects the RC (22A3354)

@christianaldas
Copy link

There’s a solution dotnet/maui#23390 (comment)

@zotanmew
Copy link
Author

There’s a solution dotnet/maui#23390 (comment)

This seems to relate to MAUI, which we are not using. I'm getting quite concerned given that we're less than a week away from public release.

@zotanmew
Copy link
Author

I also just retested this with SDK 8.0.401 & runtime 8.0.8, same result.

@christianaldas
Copy link

There’s a solution dotnet/maui#23390 (comment)

This seems to relate to MAUI, which we are not using. I'm getting quite concerned given that we're less than a week away from public release.

I'm using Blazor Wasm .Net8 I've added references to Maui WebView and works fine now!

@zotanmew
Copy link
Author

I'm using Blazor Wasm .Net8 I've added references to Maui WebView and works fine now!

Hmm, I can't get it (the blazorwasm template project mentioned in the original issue description) to build with that dependency.

/usr/local/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.8/Sdk/WasmApp.Native.targets(686,5): error : Precompiling failed for /Users/zotan/Projects/blazorwasm9/obj/Release/net8.0/wasm/for-publish/aot-in/Microsoft.AspNetCore.Components.WebView.Maui.dll with exit code 1. [/Users/zotan/Projects/blazorwasm9/blazorwasm9.csproj]
/usr/local/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.8/Sdk/WasmApp.Native.targets(686,5): error : Mono Ahead of Time compiler - compiling assembly /Users/zotan/Projects/blazorwasm9/obj/Release/net8.0/wasm/for-publish/aot-in/Microsoft.AspNetCore.Components.WebView.Maui.dll [/Users/zotan/Projects/blazorwasm9/blazorwasm9.csproj]
/usr/local/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.8/Sdk/WasmApp.Native.targets(686,5): error : Failed to load method 0x600002c from '/Users/zotan/Projects/blazorwasm9/obj/Release/net8.0/wasm/for-publish/aot-in/Microsoft.AspNetCore.Components.WebView.Maui.dll' due to Could not load file or assembly 'Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.. [/Users/zotan/Projects/blazorwasm9/blazorwasm9.csproj]
/usr/local/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.8/Sdk/WasmApp.Native.targets(686,5): error : Run with MONO_LOG_LEVEL=debug for more information. [/Users/zotan/Projects/blazorwasm9/blazorwasm9.csproj]
/usr/local/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.8/Sdk/WasmApp.Native.targets(686,5): error : AOT of image /Users/zotan/Projects/blazorwasm9/obj/Release/net8.0/wasm/for-publish/aot-in/Microsoft.AspNetCore.Components.WebView.Maui.dll failed. [/Users/zotan/Projects/blazorwasm9/blazorwasm9.csproj]

Adding another dependency for the Maui components package causes other breakages.

@zotanmew
Copy link
Author

I just tested our application on .NET 9.0 RC1 and while a simple page works fine, a more complex one causes the same crash.

@zotanmew
Copy link
Author

Interestingly, I can reproduce that crash on Safari TP Release 203 (Safari 18.0, WebKit 19620.1.6)

[Error] MONO_WASM: Out of bounds memory access (evaluating 'o.mono_background_exec()')
<?>.wasm-function[92505]@[wasm code]
<?>.wasm-function[87542]@[wasm code]
<?>.wasm-function[87592]@[wasm code]
<?>.wasm-function[84592]@[wasm code]
<?>.wasm-function[84587]@[wasm code]
<?>.wasm-function[84659]@[wasm code]
<?>.wasm-function[84689]@[wasm code]
<?>.wasm-function[61623]@[wasm code]
<?>.wasm-function[53752]@[wasm code]
<?>.wasm-function[53740]@[wasm code]
<?>.wasm-function[53736]@[wasm code]
<?>.wasm-function[53781]@[wasm code]
<?>.wasm-function[53785]@[wasm code]
<?>.wasm-function[26695]@[wasm code]
<?>.wasm-function[26694]@[wasm code]
<?>.wasm-function[26751]@[wasm code]
<?>.wasm-function[28605]@[wasm code]
<?>.wasm-function[22347]@[wasm code]
<?>.wasm-function[21371]@[wasm code]
<?>.wasm-function[22928]@[wasm code]
<?>.wasm-function[21412]@[wasm code]
<?>.wasm-function[22347]@[wasm code]
<?>.wasm-function[21975]@[wasm code]
<?>.wasm-function[21973]@[wasm code]
<?>.wasm-function[30019]@[wasm code]
<?>.wasm-function[84665]@[wasm code]
<?>.wasm-function[87542]@[wasm code]
<?>.wasm-function[87592]@[wasm code]
<?>.wasm-function[84592]@[wasm code]
<?>.wasm-function[84587]@[wasm code]
<?>.wasm-function[84659]@[wasm code]
<?>.wasm-function[84677]@[wasm code]
<?>.wasm-function[61627]@[wasm code]
<?>.wasm-function[21948]@[wasm code]
<?>.wasm-function[21968]@[wasm code]
<?>.wasm-function[23651]@[wasm code]
<?>.wasm-function[21653]@[wasm code]
<?>.wasm-function[21363]@[wasm code]
<?>.wasm-function[21395]@[wasm code]
<?>.wasm-function[21406]@[wasm code]
<?>.wasm-function[21417]@[wasm code]
<?>.wasm-function[59982]@[wasm code]
<?>.wasm-function[21407]@[wasm code]
<?>.wasm-function[21404]@[wasm code]
<?>.wasm-function[22157]@[wasm code]
<?>.wasm-function[22049]@[wasm code]
<?>.wasm-function[22048]@[wasm code]
<?>.wasm-function[59982]@[wasm code]
<?>.wasm-function[21945]@[wasm code]
<?>.wasm-function[23648]@[wasm code]
<?>.wasm-function[23836]@[wasm code]
<?>.wasm-function[59982]@[wasm code]
<?>.wasm-function[23835]@[wasm code]
<?>.wasm-function[70547]@[wasm code]
<?>.wasm-function[70492]@[wasm code]
<?>.wasm-function[23844]@[wasm code]
<?>.wasm-function[60002]@[wasm code]
<?>.wasm-function[60901]@[wasm code]
<?>.wasm-function[55238]@[wasm code]
<?>.wasm-function[60008]@[wasm code]
<?>.wasm-function[60007]@[wasm code]
<?>.wasm-function[61627]@[wasm code]
<?>.wasm-function[84665]@[wasm code]
<?>.wasm-function[87542]@[wasm code]
<?>.wasm-function[87592]@[wasm code]
<?>.wasm-function[84592]@[wasm code]
<?>.wasm-function[84587]@[wasm code]
<?>.wasm-function[84659]@[wasm code]
<?>.wasm-function[84697]@[wasm code]
<?>.wasm-function[62689]@[wasm code]
<?>.wasm-function[56085]@[wasm code]
<?>.wasm-function[56083]@[wasm code]
<?>.wasm-function[55952]@[wasm code]
<?>.wasm-function[60591]@[wasm code]
<?>.wasm-function[56771]@[wasm code]
<?>.wasm-function[53513]@[wasm code]
<?>.wasm-function[23823]@[wasm code]
<?>.wasm-function[60002]@[wasm code]
<?>.wasm-function[60901]@[wasm code]
<?>.wasm-function[55482]@[wasm code]
<?>.wasm-function[60008]@[wasm code]
<?>.wasm-function[60006]@[wasm code]
<?>.wasm-function[55284]@[wasm code]
<?>.wasm-function[55283]@[wasm code]
<?>.wasm-function[60984]@[wasm code]
<?>.wasm-function[85415]@[wasm code]
85415@[native code]
Yo@http://localhost:3000/_framework/dotnet.runtime.26xtx0erx2.js:3:55998
callUserCallback@http://localhost:3000/_framework/dotnet.native.ck80easzdg.js:8:86558
@http://localhost:3000/_framework/dotnet.native.ck80easzdg.js:8:86838
	y (dotnet.js:3:1180)
	(anonymous function) (dotnet.js:3:27621)
	at (dotnet.js:3:27905)
	Yo (dotnet.runtime.26xtx0erx2.js:3:56024)
	callUserCallback (dotnet.native.ck80easzdg.js:8:86559)
	(anonymous function) (dotnet.native.ck80easzdg.js:8:86839)
[Error] RuntimeError: Out of bounds memory access (evaluating 'o.mono_background_exec()')
	quit_ (dotnet.native.ck80easzdg.js:8:448)
	handleException (dotnet.native.ck80easzdg.js:8:86363)
	callUserCallback (dotnet.native.ck80easzdg.js:8:86598)
	(anonymous function) (dotnet.native.ck80easzdg.js:8:86839)

@zotanmew
Copy link
Author

Oh hold on, this is the same result as I mentioned in the original post. So nothing has changed.

@constshift
Copy link

constshift commented Oct 11, 2024

We have the same problem. iOS 18 crashes with MONO_WASM: Exception marshalling result of JS promise to CS: (dotnet.runtime.8.0.7.e9r13h23hd.js, line 3)
RuntimeError: Out of bounds memory access (evaluating 'St.mono_wasm_write_managed_pointer_unsafe(t,e)')

The dotnet/maui#23390 (comment) fix does not work with our Blazor WASM application.

Many of our iOs users are reporting the problem to us. Would be nice if this problem could be fixed asap.

@MattParkerDev
Copy link

Also getting the same issue, occurs on my personal blog website: https://mattparker.dev/. Source code is here: https://github.com/MattParkerDev/MattParkerDev.Blog

Running iOS 18.0.1 on an iPhone 14 Pro.

Refreshing the page over and over, it will fail ~4/5 times.

@mip1983
Copy link

mip1983 commented Oct 17, 2024

I'm getting the same on our Blazor web app, .NET 8.0.10 SDK and nuget packages, phone on IOS 18.0.1

@LeeroyGgJenkins
Copy link

LeeroyGgJenkins commented Oct 17, 2024

We are having the same Issue in our .Net8 blazor wasm hosted application, it has been in production for over a year and no major changes have been made.
Too add some context these errors are raised when inspecting a problematic device web console.

dotnet.js:4 Error in mono_download_assets: Error: download 'https://[redacted].azurewebsites.net/_framework/dotnet.native.wasm' for dotnet.native.wasm failed 0 TypeError: Load failed
errorHandling.js:132 Unhandled rejection: Error: download 'https://[redacted].azurewebsites.net/_framework/System.ClientModel.wasm' for System.ClientModel.wasm failed 0 TypeError: Load failed
errorHandling.js:132 Unhandled rejection: Error: download 'https://[redacted].azurewebsites.net/_framework/System.Drawing.Common.wasm' for System.Drawing.Common.wasm failed 0 TypeError: Load failed

[...]
and so on until finally this error is reached
"dotnet.runtime.8.0.8.80cvijctdx.js:4 MONO_WASM: Exception marshalling result of JS promise to CS: RuntimeError: Out of bounds memory access (evaluating 'St.mono_wasm_write_managed_pointer_unsafe(t,e)')"

Basically every file with a '.wasm' is returning an Error.

@iXyles
Copy link

iXyles commented Oct 18, 2024

We have been seeing same thing with our application and only affects iOS18>, but it breaks in all browser types and not only Safari. It also breaks on latest MacOS in safari, but works in other browsers.

@zotanmew
Copy link
Author

That makes sense, all browsers on iOS use the same WebKit engine internally.

@mip1983
Copy link

mip1983 commented Oct 21, 2024

@radekdoulik Is there any potential work arounds for this? I'm a bit concerned by the .NET 10 milestone for something quite so production critical.

@Light407
Copy link

Any update on this? Having the same issue

@iXyles
Copy link

iXyles commented Oct 25, 2024

@pavelsavara any chance to get some attention regarding this problem, as it is starting to affect more and more end users as they update to newer versions of ios and MacOS. Tagging you due to area owner of browser.

@constshift
Copy link

For now, we turned off AOT, and that seems to work at least, but we would like this to be fixed eventually.

@neseih
Copy link

neseih commented Oct 29, 2024

IOS 18.1 seems to have fixed it for me.

@zotanmew
Copy link
Author

IOS 18.1 seems to have fixed it for me.

I can indeed not reproduce the issue anymore on iOS 18.1 (22B83) 🎉

I did occasionally get the "A problem repeatedly occurred on [site]" message, but I think that's unrelated and happens with non-blazor sites as well, especially when reloading quickly and frequently.

@MattParkerDev
Copy link

iOS 18.1 has also resolved for me.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono os-browser Browser variant of arch-wasm
Projects
None yet
Development

No branches or pull requests