/dotnet9-watch-slow-repro

Repro for https://github.com/dotnet/sdk/issues/47179

Primary LanguageCSS

Repro for slow dotnet watch with Blazor on .NET9

Related:

Problem

  1. dotnet watch is slower on net9 than net8, in particular the first change can take 10-20 seconds vs a few seconds for a trivial change to .razor files in our large Blazor Server app. (1)
  2. Blazor seems to do a page reload after hot reload in our app, but have not yet been able to create a repro of this behavior in these sample apps. See details below.

(1) In 9.0.2 SDK release, the hot reload was 10-20x slower for every change, but in 9.0.3 SDK release only the first hot reload is 10-20x slow and subsequent changes are fast.
9.0.104, 9.0.202 and 9.0.300-preview.0.25174.3 all exhibit the slow first hot reload, and in our app, also a special page reload.
In our app, these versions also do a special page reload upon hot reload. Details below.

To run this sample

Run both projects in two separate shells:

dotnet watch --verbose --project Blazor8
dotnet watch --verbose --project Blazor9
  • Wait for browser to launch for each project.
  • Edit Components/Pages/Home.razor in either project, and change the title text or something trivial.

Observations in template apps

  • Simulating a slow OnInitializedAsync with Task.Delay, delays the hot reload on both (probably by design)

Observations in our large Blazor Server app

  • On net9, hot reload incurs what seems like a special page reload. The circuit stays connected and no new HTTP GET request to Blazor, but the page is pre-rendered again, and all scoped services are recreated and re-initialized.
  • This page load is slow in our app and delays hot reload, and this did not happen in net8 SDK.

image

image