razor: Razor Tooling: VS is very slow when changes are made to .razor-based components
Describe the bug
Whenever I make type-structure-related changes to Blazor components inside .razor files VS becomes very unresponsive, CPU usage goes up and this continues for ~30 seconds.
The changes that trigger this behavior are the following:
- Adding a new property with
[Parameter]
attribute to the@code {}
section inside of*.razor
file. - Changing the name or return type of such a property
- Adding a new
*.razor
file - Renaming or moving
*.razor
file from one folder to another - Editing any of the
_Imports.razor
files in any way
So, presumably, every time I make a change that affects the components behavior (like which parameters are available, which components are in scope, etc.) VS must be doing a heavy rebuild of everything related to this change and that causes it to be very unresponsive.
Further technical details
- ASP.NET Core version: 5.0.0-preview.4.20257.10
- Include the output of
dotnet --info
:
.NET SDK (reflecting any global.json):
Version: 5.0.100-preview.4.20258.7
Commit: 65f0fc2cad
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-preview.4.20258.7\
Host (useful for support):
Version: 5.0.0-preview.4.20251.6
Commit: 47ec733ba7
.NET SDKs installed:
3.1.300-preview-015135 [C:\Program Files\dotnet\sdk]
5.0.100-preview.4.20258.7 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.4.20257.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.4.20251.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.4.20251.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
- The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version: latest preview - VS 2019 16.7 Preview 1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 25 (5 by maintainers)
It would be nice if someone that was actually in charge of fixing this would give some kind of update. The product is unusable in it’s current form. Period. I am waiting 20 seconds between tying characters at this point. This is not a performance issue - it is a bug. Have started recommending we abandon this Blazor / .Net core stuff since it is clearly not ready for production if we can’t even get working tools. 30 days open and no updates is just crazy.
Is ANYONE able to actually do editing in any version of VS2019 with blazor/razor pages?
Since apparently my tracing of this this has been moved from the VisualStudio site to here (from this link: https://developercommunity.visualstudio.com/content/problem/1075952/very-slow-intellisense-in-blazor-project.html ) I will start following here.
I have all the same issues as described above. This makes the product unusable. I am also editing code using Visual Studio Code, and then having it update/compile in VS 2019 v 16.6.2 (.net core 3.1) Once it gets itself wrapped up in the delays the only real solution is restarting the entire virtual machine I am running in. Closing and killing all the abandoned VS pieces never releases the leaked 10+GB of memory and performance will never really come back without a reboot.
My current project is a single razor page (about 1200 lines of markup/code) Everything else is just the standard boilerplate for a Blazor Server project.
I see a lot of closed issues that are not resolved and one suggestion of kicking this can down the road as just an annoyance. This makes the concept of trying to code a Blazor project with VS a non-starter.
This absolutely has not been fixed and in fact seems worse. The only thing that appears to help is once I get the JSON-RPC error message posed by fitdev above, it seems things work better. Guessing that process has something to do with the slowdown, although not all of it.
It would be nice to not just keep closing tickets before verifying they are complete.
Are we supposed to start another ticket and start this process all over again?
@fitdev never feel bad about giving loads of updates. We appreciate all the help we can get. You mentioned:
Would you mind capturing a PerfView trace of what’s happening when you’re editing your C# Blazor component files.
We’re working really hard in fixing all of these issues in 16.7-Preview4. There’s already loads of performance improvements we’ve gotten into the release that we’re excited for the community to try. We’re currently in the process of digging through everyone’s ETL traces/dumps to ensure the work we’ve done so far has accounted for the nuisances you’ve all been encountering 😄
I’ve finished digging through all of the dumps and etl traces and we’ve accounted for all of the major performance issues present in them!
That being said there was 1 extra smaller performance issue I found when digging that we’ll fix in 16.8-Preview1. It doesn’t have a big enough footprint to warrant fixing it in 16.7-Preview4 so I envision most issues will be resolved then.
For now i’m going to close out this issue but @fitdev feel free to still respond here with information if you’re able to get it and i’ll follow up.
Installed VS 16.7 Preview 4. Enabled “Experimental Razor Editor”. Now VS freezes a few seconds after opening/previewing any .razor file and needs to be restarted. Actually this behavior was there even in previous VS previews.
Disabled “Experimental Razor Editor”. There was a short 10-second freeze after previewing first .razor file, then after making a few edits everything seemed to be ok. However VS reported that a process it uses crashed (did not say which one):
Though I am not sure at this point if this process crash is related to Razor Tooling.
Will report more info as I test it out.