Repository navigation
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
Activity
radical commentedon Dec 1, 2023
cc @pavelsavara @maraf
[-][browser] Setting `maxParallelDownloads` sometimes has no effect[/-][+][wasm] Setting `maxParallelDownloads` sometimes has no effect[/+]pavelsavara commentedon Dec 1, 2023
It is unrelated, except it uses same bandwidth, right ?
It's set in
mono_download_assetsand I guess we could move it earlier tomono_wasm_load_configWhich is before
start_asset_download_with_throttlewas ever called, and soparallel_countwould be0we don't want to create multiple instances of
throttlingPromiseat the same time I think.MackinnonBuck commentedon Dec 1, 2023
Right, I was testing if reducing the bandwidth occupied by WebAssembly resource downloads would improve the quality of the websocket connection (and my results indicate that it does make a difference).
fix dotnet#95491
[browser][fix] maxParallelDownloads
fix #95491
[release/8.0-staging] [browser][fix] maxParallelDownloads (#95870)