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

.Net 9 Blazor MapStaticFiles unusable #61008

Open
1 task done
s-beji opened this issue Mar 19, 2025 · 0 comments
Open
1 task done

.Net 9 Blazor MapStaticFiles unusable #61008

s-beji opened this issue Mar 19, 2025 · 0 comments
Labels
area-blazor Includes: Blazor, Razor Components investigate

Comments

@s-beji
Copy link

s-beji commented Mar 19, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I currently develop a Blazor component library and started with .net 8
I partially ported to .net 9 a few weeks ago and yesterday i completed it with using MapStaticFiles instead of UseStaticFiles.

I was on the review process and tested the demo library and was surprised to see a lot of GC events and a massive consumption of 600mb on startup and the startup itself took longer, but that was expected since MapStaticFiles does compression and fingerprinting of the files.

But the 600mb got me stubbled, and I first suspect my custom logging solution since it's been not long ago which where I introduced it, so I went to the master branch where I did not have included it yet since I have not finished the release bundling. The master branch was at 57mb startup that's reliving, so I went to develop to confirm it's the logging and oh no it still around 57 and barely any GC events, so I was continued looking till I discovered it was the feature branch I were working on the MapStaticFiles port to complete the migration to .net 9. UFF I was looking more into the issue and could confirm it's the staticfiles feature I analyzed the heap by my best ability. I created a reproduction project, taking just the .net 9 Blazor template and reverting it to use UseStaticFiles

There the impact of the startup was not that huge (expected since there are only 3 static assets mapped compared to my lib which has around 12) but somehow the difference is just 2x more memory consumption compared to my lib which suffered a 10x increase. So I assume it increases on a linier basis relative to the amount of static files served, but that's only a rough guess though the collected data

Expected Behavior

A slight reduction of runtime memory and not an increase and raw startup time should be similar *(not build time mentioned) since the mapping will be done on build time as far I understood through the docs and presentation of the .net 9 release

Steps To Reproduce

Just take the repo and run it to confirm the same results that i gathered on my machine via performance profile

I create 2 separate project based on the latest .net 9 Blazor web app template, the only difference is that one is unmodified and one modified to use the old UseStaticFiles

Reproduction Project

Exceptions (if any)

That seems like the feature is not ready for shipment if it's not an edge case bug, since I can see a lot of project would suffer if they use it right now in this condition.

For me, I invested now my whole night to gather the intel and report it properly
But regardless of that I know I can't use the feature at this stage and need to push back the feature branch out of my planned release and will need to wait till Microsoft pushes hopefully soon a patch for that major issue since for me 10x increase memory is unbearable.

Personally I hope my invested time was not a waste

.NET Version

9.0.200

Anything else?

All data can be found in the Reproduction Project

!Failed to upload "BlazorAppWithMapStaticAssets-BuildLog.txt" --> Can be found on the repo project
BlazorAppWithMapStaticAssets-Counters.txt
BlazorAppWithMapStaticAssets-DebugLog.txt
!Failed to upload "BlazorAppWithUseStaticAssets-BuildLog.txt" --> Can be found on the repo project
BlazorAppWithUseStaticAssets-Counters.txt
BlazorAppWithUseStaticAssets-DebugLog.txt
DotNetEnvorimentInfo.txt
SystemEnvorimentInfo.txt

MapStaticFiles

Image
Image

UseStaticFiles

Image
Image

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Mar 19, 2025
@javiercn javiercn added this to the .NET 10 Planning milestone Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components investigate
Projects
None yet
Development

No branches or pull requests

2 participants