-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 WebAssembly crashes on mobile devices with low RAM #61925
Comments
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, |
Yes, I'm seeing the crash on Chrome on Android as well. I'm using the latest version of chrome (95.0.4638.74) |
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) (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) |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@lewing FYI |
Possibly related, this was also in the debug window when the above errors showed up in the console: |
Tagging subscribers to this area: Issue DetailsDescribe the bugBlazor WebAssembly apps crash on devices with low RAM To ReproduceI have created a minimal example at https://github.com/martinmogusu/CrashTest 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"
I was able to view the console logs by using Kiwi Browser for android, which has devtools. Further technical details
dotnet --info Output
|
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescribe the bugBlazor WebAssembly apps crash on devices with low RAM To ReproduceI have created a minimal example at https://github.com/martinmogusu/CrashTest 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"
I was able to view the console logs by using Kiwi Browser for android, which has devtools. Further technical details
dotnet --info Output
|
I am not sure mine have the same root cause as yours. I ran a memory profile on chrome desktop version with .net 6 wasm published to IIS. The barebone template project is using 540mb memory compare to .net 5's 40mb. It is unacceptably high memory usage on a almost blank project. It is causing the whole application crashes after a few operations. I hope someone can take this seriously. It is NOT a small issue. Please refer to the issue below. The issue is not reported by me but I have the same symptom and I uploaded a few screenshots. P.S. .net 6 + wasm + kestrel (ctrl + F5 via VS) is not having this memory issue. |
Is there any update on this issue. We have run into the same thing. Looks like it's not going to be fixed in .net 7 and pushed out to .net 8. Has anyone got any workarounds for this? At the moment there looks like no other solution but to pull back to .net 5. MS guys on ticket, this is hardly a small issue is it. There are many devices with low ram |
Hi folks, |
Hi all I wanted to chime into this issue more, because I believe it's much more serious than MS believe it to be. Other people in this thread have been using relatively low-end phones, but I've tested this across a variety of devices, not just low end but iPhone 11, and some flagship samsung phones that're a bit older. I believe the threshold is devices 4gb and below. I've taken an empty blazor WASM project and deployed it to azure, nothing fancy, no additions, no nothing, just a plain Blazor WASM app. The initial load is absolutely shocking, hitting a second by second usage of 1.91GB of ram. It absolutely should not be hogging this amount of memory. From this point on you can force an exception simply by refreshing the page, where you can see the max usage hits 3.26gb of RAM. Which again is madness for just an empty app. When hitting this amount it hits an exception: Now I get the iphone 11 is hardly a new phone being released in 2019, but reality is, this is this is reflective of most people walking around with a mobile device today. This needs a fix, at the moment I'd actively discourage anyone that's developing for mobile users to avoid using Blazor WASM until it's fixed. |
Not supprised by this if your using net 6 blazor wasm. A few issues have been reported around memory leaks and crashes. Barely have any of them been fixed. We have to use.net 5 which is at least not broken. It has been like this for a year and not sure this will be resolved in.net 7 or not. |
I had the same problem, I fixed it by removing all OnAfterRenderAsync methods, I don't know the root cause but it worked for me. |
I'm having the same issue. No way can I use Blazor 6 or 7 until this is fixed. This is a major issue. |
I am having the same issue. To say that this is major is an understatement.... |
I will spend some time next year on looking on this, but for now some hints:
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. |
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? 😅 |
Did |
This helped in my case. I've gone from seeing 3.5-4gb of memory consumed within a few actions to under 1gb. Thank you |
@simpsoc Which value did you define for xxx? <EmccTotalMemory>xxx</EmccTotalMemory> |
I set it to 16777216(1024(bytes) x 1024(kilobytes) x 16 = 16MB). I had seen another post that was mostly msft engineers discussing the issue earlier in the year. I think I initially found it by searching my specific error message. This was a value that someone mentioned fixing the issue in their testing. The discussion seemed to mostly focus around implementing the ability to make the change vs the change already being something that could be made. I did some googling around EmccTotalMemory and webassembly, blazor, wasm keywords but the only results I found were for emscripten, which is a 3rd party webassembly compiler that is used for building the webassembly. Without any results or documentation focusing around blazor i didn't realize it was a configurable parameter. @pavelsavara suggesting changing that value in csproj and adding the native build flag is as close to any instructions or documentation as I've seen for this. His suggestion triggered my memory to go back and look at that thread for the value they'd used. |
Searching for
It 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-tools workload installed!
workload will pass this 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. |
questions: @radical @lewing @maraf @kg
Same questions as in #66313 |
Fixed by #80849 |
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:
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
dotnet --info
:dotnet --info Output
The text was updated successfully, but these errors were encountered: