Repository navigation
Blazor WebAssembly crashes on mobile devices with low RAM #61925
Copy link
Copy link
Closed
Labels
Milestone
Description
Describe the bug
Blazor WebAssembly apps crash on devices with low RAM
To Reproduce
I have created a minimal example at https://github.com/martinmogusu/CrashTest
The code is from the default WebAssembly template dotnet new blazorwasm
I have also hosted the site on Azure Static Web Apps here: https://icy-sky-0892af903.azurestaticapps.net/
If you load the site on a device with 1GB RAM, the app crashes. On the UI you see "An unhandled error has occurred"
On the browser console logs you find this error:
Uncaught (in promise) TypeError: Failed to execute 'arrayBuffer' on 'Response': body stream already read
TypeError: Failed to execute 'arrayBuffer' on 'Response': body stream already read
window.Module.s.printErr @ blazor.webassembly.js:1
I was able to view the console logs by using Kiwi Browser for android, which has devtools.
The same site works okay on devices with higher RAM.
Further technical details
- ASP.NET Core version: 6.0
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: Visual studio 2022
- Include the output of
dotnet --info:
dotnet --info Output
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
3.1.301 [C:\Program Files\dotnet\sdk]
3.1.415 [C:\Program Files\dotnet\sdk]
5.0.403 [C:\Program Files\dotnet\sdk]
6.0.100-rc.1.21463.6 [C:\Program Files\dotnet\sdk]
6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Reactions are currently unavailable
Activity
TanayParikh commentedon Nov 16, 2021
Were you seeing a crash in Chrome as well? Supported browsers are listed here: https://docs.microsoft.com/en-us/aspnet/core/blazor/supported-platforms?view=aspnetcore-6.0. Note,
Kiwiisn't on the list of supported browsers.martinmogusu commentedon Nov 16, 2021
Yes, I'm seeing the crash on Chrome on Android as well. I'm using the latest version of chrome (95.0.4638.74)
frieddumplings commentedon Nov 20, 2021
Also seeing it in chrome beta/android 97.0.4692.20.
The website just gives the "An unhandled error has occured. Reload" message - (clicking on reload for me dosen't actually do anything).
.Net Core 6.0 empty/default client/server project (nothing changed).
Using a VPS that has 2GB of ram to host my page (Just the default client/server template) . It seems to be okay when navigating normally using buttons/clicking on links, but if I modify the url through the search bar (by typing) I get this error quite frequently. Phone is a Galaxy S9 SM-G960F running android 10.
I've tested on an older version of chrome as well (80.0.3987.99) and its harder(?) or almost impossible to reproduce the error.
edit (this older version was chrome stable)
(Also forgot to mention, blazor project. If that makes any difference).
(Edit again: Added a list of server processes) CPU** and ram usage hovers around 30~50%. Haven't really monitored when changing pages but shouldnt(?) be an issue, nothing fancy installed. Just SQLServer and a bunch of default stuff)
mkArtakMSFT commentedon Nov 22, 2021
@lewing FYI
frieddumplings commentedon Nov 23, 2021
Possibly related, this was also in the debug window when the above errors showed up in the console:
https://blog.chromium.org/2021/05/update-on-user-agent-string-reduction.html
https://blog.chromium.org/2021/09/user-agent-reduction-origin-trial-and-dates.html
10 remaining items
pavelsavara commentedon Dec 22, 2022
I will spend some time next year on looking on this, but for now some hints:
<EmccTotalMemory>xxx</EmccTotalMemory>in your .csproj file together with<WasmBuildNative>true</WasmBuildNative>or with AOT. Where xxx is memory size which still works for your app.Remember that memory requirements of your app is not all we need here. We also expand IL->IR for interpreted methods. And the browser JIT will have to compile all the code too, consuming CPU and memory.
Perhaps for low powered mobile devices, consider server side rendering, where possible.
Maybe we should define some minimal spec on which WASM is supported.
Pethical commentedon Dec 22, 2022
The headers are ok in my application. I have a Samsung Galaxy Note 10+ phone and the application can't load because this problem. If this is a low powered phone, then please tell me what is a high end device. And what can I define as minimum spec? A phone with 64Gb ram and 32 arm cores? 😅
Basically, net 5 is working like a charm, so I downgraded my apps. This is a security flaw and can cause problems, but no other way exists. The net 5 is the Windows XP today. We can't upgrade. 😂
pavelsavara commentedon Dec 22, 2022
Did
EmccTotalMemoryhelp?boukenka commentedon Dec 26, 2022
@simpsoc Which value did you define for xxx?
pavelsavara commentedon Jan 5, 2023
Searching for
Module["INITIAL_MEMORY"]in the finaldotnet.jsgives me following answers for vanilla Blazor templateIt is set here
runtime/src/mono/wasm/build/WasmApp.Native.targets
Lines 190 to 191 in 70aadaf
and applies for customers anytime they do relink (even without AOT) for example via
<WasmBuildNative>true</WasmBuildNative>or by just having
wasm-toolsworkload installed!workload will pass
--initial-memory=536870912to emccthis is probably the PR which introduced it #52941 which is Net6 timeframe
I was not able to replicate the issue with the repro repo without relink.
pavelsavara commentedon Jan 5, 2023
questions: @radical @lewing @maraf @kg
Same questions as in #66313
pavelsavara commentedon Feb 24, 2023
Fixed by #80849