Blazor WASM applications on net8.0 freeze on startup on iOS 18 RC (22A3354) when built with AOT
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
dotnet new blazorwasm- Run
dotnet publish -p:RunAOTCompilation=true - Run
python3 -m http.server 9000 -b 0.0.0.0 -d bin/Release/net8.0/publish/wwwroot - 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
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).~~ https://github.com/dotnet/runtime/issues/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 accessino.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.
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.
Since this may be an iOS bug, I filed a radar with Apple (FB14644808) containing a link to this issue.
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.
Beta 6 (22A5338b) has the same behavior as Beta 5.
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.
Beta 8 (22A5350a) has the same behavior as Beta 6.
Still affects the RC (22A3354)
There’s a solution https://github.com/dotnet/maui/issues/23390#issuecomment-2286943437
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 also just retested this with SDK 8.0.401 & runtime 8.0.8, same result.
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!
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.
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.
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)
Oh hold on, this is the same result as I mentioned in the original post. So nothing has changed.
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 https://github.com/dotnet/maui/issues/23390#issuecomment-2286943437 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.
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.
I'm getting the same on our Blazor web app, .NET 8.0.10 SDK and nuget packages, phone on IOS 18.0.1
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.