-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Summary
Configuring maxParallelDownloads via the dotnet JS API sometimes doesn't have an effect, and WebAssembly resources are still downloaded with maximal parallelism.
Description
I found this issue when attempting to throttle WebAssembly resource downloads in a Blazor Web app to see how the throttling affected websocket connection quality. Locally, I was able to fix the problem my changing an == to a >= on this line:
| if (parallel_count == loaderHelpers.maxParallelDownloads) { |
I wasn't able to fully debug the underlying cause of the issue, but I believe what happens is the value for loaderHelpers.maxParallelDownloads has its default value of 16 for the first asset or so, but then later respects the value provided via builder.WithConfig(). So if the configured limit is less than 16, the case where the number of current downloads is exactly the configured limit might be skipped, which causes unbounded parallelism.
Steps to reproduce
- Create a Blazor Web App with "Auto" interactivity
- e.g.,
dotnet new blazor -int Auto
- e.g.,
- Replace the
blazor.web.jsscript reference inApp.razorwith the following:<script src="_framework/blazor.web.js" autostart="false"></script> <script> Blazor.start({ webAssembly: { configureRuntime: (builder) => { builder.withConfig({ maxParallelDownloads: 1, }); }, }, }); </script>
- Run the app with Microsoft Edge as the selected browser
- In the browser's dev tools, go to the "Network" tab and select "Fast 3G" throttling (to make it easier to see the parallelism)
- With the dev tools window left open, navigate to the
Counterpage - Observe that WebAssembly resources are downloaded in parallel