Hot Reload Takes Nearly 45 Seconds to Update
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] Please see attached. Hot Reload now works for me, but takes forever to update, nearly 45 seconds to be more precise.
Original Comments
Feedback Bot on 11/11/2021, 03:48 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
Original Solutions
(no solutions)
@pranavkm I know that you've been looking into this already. Is there another issue to dupe this against?
More reports:
- https://developercommunity.visualstudio.com/t/VS2022-with-Blazor-Server-project-is-ter/1584485
same for me its just not flawless yet... :(
This is a duplicate of https://github.com/dotnet/aspnetcore/issues/32867. Workaround can be found here: https://developercommunity.visualstudio.com/t/Hot-Reload-in-VS-very-slow-but-fast-wit/1563649
I have similar issue, but just a lot worse.
For a slightly complicated page (~450 lines of razor, a few loops etc.) hot-reload from VS2022 takes 2:30 (2 minutes and 30 seconds) of really hammering the CPU to apply changes, and after that the changes still does not get rendered, and I have to restart the app.
Using the suggested workaround using dotnet watch it "only" takes 50-80 seconds. But now it actually also renders the changes.
It's only this extreme for this particular page. For very simple pages it's working OK, and changes are applied within 10 seconds. I've tried to find if it's any particular code on this page that is "bad" by process of elimination, and I can't find any specific error but in-line loops just seems to absolutely kill the performance.
I do apologize for the confusion here. According to this comment, this should have been addressed in preview2? This was my understanding when I posted my last comment, which seems to have contributed to the issue being locked. 😇
But now it appears with subsequent updates that this is slated for .NET7, if I understand correctly. I am totally fine with this as long as it is being communicated correctly so that we're not operating under false impression/understanding. For instance, I wouldn't have posted my last comment on dotnet/aspnetcore#32867 as I was under the impression that a fix had already been checked in as per the previous comment (which I probably misunderstood).
In any case, please know that I for one truly appreciate all the effort being applied there with this task and the project as a whole. You are truly moving mountains over there. 🙏
Based on this PR, it is being backported to .NET 6.0.3: https://github.com/dotnet/sdk/pull/23419
It was told that it will come in VS 17.2 (see last comment in the PR linked above). I don't know the ETA for that. Even 17.1 is yet to be released.
Ahhhhh 17.2, not to be confused with 17.1 Preview 2, as I was doing. :) Thank you for the pointer and correction, @CommonLoon102.
@Mike-E-angelo 17.2 preview1 would ship the same day 17.1 ships (part way thru February 2022).
17.2 Preview 1 is out but it is still 40 seconds to do a "hot" reload.
Not really related to this issue other than if I wasn't doing this, then I wouldn't be here in the first place. :) I recently announced my product that is built on your tech and is responsible for finding all these issues. 😁
https://alpha.starbeam.one/about/acknowledgements
I have a shout out to you there @pranavkm. Thank you for all your great work over there. 🙏
Me and my team are working on a big scale project right now and we decided to update to .NET 6.0 and we have the same issue with our windows users. It looks like it works perfectly fine in the M1 Mac version. Also we noticed that some of our code that includes SQL Server works slower, noticeably slower. I, myself, use hot reload very much but i don't mind debugging every time, but it's the same speed so i do not bother.
https://github.com/dotnet/sdk/pull/24538
🤔
No comment given on the reversion, but it appears it was leading to problems such as this one, which I ran into yesterday: https://developercommunity.visualstudio.com/t/perpetual-15-20-cpu-churn-by-servicehubroslyncodea/1703772
(Reference: https://github.com/dotnet/razor-tooling/issues/5697#issuecomment-1080942033)
Is there still any hope that the community will get a 3-4 seconds hot-reload time instead of 40-45 seconds? Is this still considered fixable? The issue is there since .NET 6 release and the new previews didn't bring any improvements. I also can't see a fix for this in the .NET 7 roadmap. I'm asking because we need to consider this when we deciding about the technology we want to use in new projects.
Not looking too promising here. Any further update, @pranavkm?
I do most of my development using dotnet watch -- the hot reload rarely takes more than 5 seconds there. At least when it deigns to use it, anyway; there's a lot of seemingly innocuous changes that it apparently considers to be rude. The VS debugger seems a bit random on whether it will stop on breakpoints or not anyway, so I try to use it only when I can't find out what the app is up to any other way.
I do most of my development using
dotnet watch-- the hot reload rarely takes more than 5 seconds there.
It depends on the file you edit. I have files which reload in a second with dotnet watch, others take more, some can take up to 45 seconds. Although I just change some text in a <span>, it still takes 45 seconds...
For the VS hot reload performance we have a PR out in the SDK repo, which should improve things. https://github.com/dotnet/sdk/pull/24928
For dotnet watch and even faster VS we have some ideas of how to improve the performance, but don't have any concrete timelines yet.
Thank you for taking the time to update us, and for all your efforts out there @chsienki & team. 🙏
Any update with this issue, by chance? I have yet to use Hot Reload once for my Blazor solution. Well, outside of it taking a minute or so for it to work and reporting it here as a bug. :P
It takes mine ~28 seconds to update on a relatively small blazor project with some Telerik controls.
I am using a 10core, 64gb machine, I am using .NET 7.0 as well.
I am using dotnet watch run / dotnet watch
The workaround posted does nothing for me
It actually a lot faster if i Ctrl+C and dotnet watch run / dotnet watch again
What is the latest on this please?
I love the tech but it's so disheartening when fixing a typo in an html class and then having to wait over a minute for that change to appear on the UI. It just destroys productivity.
Does anyone have any workarounds or am I best to abandon hot reload and just rebuild and retest every now and again?
dotnet watch ⌚ File changed: ./.Client/Pages/Activity.razor.
<LONG WAIT>
dotnet watch ⌚ Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
dotnet watch ⌚ Received successful apply from delta applier.
dotnet watch 🔥 Hot reload of changes succeeded.
dotnet watch 🔥 Hot reload change handled in 6212834.683ms.
@Drammy @zoinkydoink @Mike-E-angelo and others experiencing very long (>20s) hot reload times: are you all working on Blazor WebAssembly projects? Has anybody experienced these very long times in Visual Studio when working on Blazor Server projects?
Blazor server here, @DamianEdwards. I have yet to ever see Hot Reload work once in a viable way while in Visual Studio. FWIW I am also the one who reported the original issue on developercommunity under a previous account, and this should reflect a Blazor server project as well.
@DamianEdwards I am using Blazor Server side, I tracked down my issue further. It seems that having about 20-30 controls (html and mixed with telerik blazor) was actually the issue. If i have a blank blazor page with minimal stuff on it then hot reload is instant. so it has something to do with having too many elements on the page.
I gave up using hot reload on this page because the next thing i needed to do was redesign my page with more components than just straight up html/telerik controls directly on the page.
All in all, do a lot of testing with many controls and figure out why that is an issue.
Thanks for following up though
@Drammy @zoinkydoink @Mike-E-angelo and others experiencing very long (>20s) hot reload times: are you all working on Blazor WebAssembly projects? Has anybody experienced these very long times in Visual Studio when working on Blazor Server projects?
@DamianEdwards We're developing Blazor web assembly using Rider on a Mac, so just the dotnet command line tools for us.
For what its worth I've refactored the large page component down into numerous smaller components and the hot reload performance is much better.
You could also try moving out components to separate projects, even to multiple projects. And only have the pages in one project which just using the components. I'm not sure if it would help on the performance, but worth a try.
See also: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1465553