Skip to content

[browser][coreCLR] throttling + WBT#124969

Merged
pavelsavara merged 5 commits intodotnet:mainfrom
pavelsavara:improve_throttling
Mar 2, 2026
Merged

[browser][coreCLR] throttling + WBT#124969
pavelsavara merged 5 commits intodotnet:mainfrom
pavelsavara:improve_throttling

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Feb 27, 2026

  • enable throttling for all file types.
  • leaveThrottling(); after instantiation for some of them
  • add optional asset.priority for later use
  • make sure that onDownloadedAsset(); is counted even when it fails
  • fix webcil name

Fixes #124900

@pavelsavara pavelsavara added this to the 11.0.0 milestone Feb 27, 2026
@pavelsavara pavelsavara self-assigned this Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 14:24
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Feb 27, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the download throttling mechanism in the browser WASM loader. The main changes include renaming the "webcil10" asset behavior to "webcil", splitting the old noThrottleNoRetry map into separate noRetry and noBuffer maps, and restructuring throttling logic to better handle assets that don't buffer immediately (such as dotnetwasm, webcil, and symbols).

Changes:

  • Renamed "webcil10" to "webcil" (breaking API change) in public-api.ts and dotnet.d.ts
  • Added priority field to AssetEntryInternal for potential future priority-based download handling
  • Refactored fetchWasm to fetchMainWasm and restructured throttling logic with new enterThrottling() and leaveThrottling() helper functions
  • Split old noThrottleNoRetry map into noRetry (for disabling retries) and noBuffer (for skipping immediate buffering)
  • Added try-finally blocks to fetch functions for better error handling and resource cleanup

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/native/libs/Common/JavaScript/types/public-api.ts Renamed "webcil10" to "webcil" in AssetBehaviors type (breaking change)
src/native/libs/Common/JavaScript/types/internal.ts Added optional priority field to AssetEntryInternal for throttling bypass
src/native/libs/Common/JavaScript/loader/run.ts Updated import and call from fetchWasm to fetchMainWasm
src/native/libs/Common/JavaScript/loader/dotnet.d.ts Renamed "webcil10" to "webcil" in type definitions (breaking change)
src/native/libs/Common/JavaScript/loader/assets.ts Major refactoring: renamed fetchWasm to fetchMainWasm, extracted enterThrottling/leaveThrottling helpers, split noThrottleNoRetry into noRetry and noBuffer maps, added try-finally blocks for error handling, and updated webcil10 references to webcil

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 9 comments.

Copilot AI review requested due to automatic review settings March 1, 2026 13:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

src/native/libs/Common/JavaScript/loader/assets.ts:504

  • onDownloadedAsset assigns asset.buffer = null!, which sidesteps the declared type (ArrayBuffer | Promise<ArrayBuffer> | undefined) and forces a non-null assertion. Consider setting it to undefined instead so the runtime value matches the type and you can drop the null! cast while still releasing memory.
    // release memory
    asset.buffer = null!;
    asset.pendingDownload = undefined;

src/native/libs/Common/JavaScript/types/internal.ts:65

  • The newly introduced inprogress field is inconsistent with the existing camelCase naming (e.g., useCredentials, pendingDownload). Consider renaming it to inProgress (and updating its uses) to keep naming consistent and reduce confusion.
    priority?: boolean
    shortName?: string
    inprogress?: boolean
}

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 1, 2026 13:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.

@pavelsavara
Copy link
Member Author

Passing test Log

[log] TestOutput -> Fetch started. Active downloads: 4
[log] TestOutput -> Fetch completed. Active downloads: 3
[log] TestOutput -> Fetch completed. Active downloads: 2
[log] TestOutput -> Fetch completed. Active downloads: 1
[log] TestOutput -> Fetch completed. Active downloads: 0
[log] TestOutput -> Fetch started. Active downloads: 1
[log] TestOutput -> Fetch started. Active downloads: 2
[log] TestOutput -> Fetch started. Active downloads: 3
[log] TestOutput -> Fetch completed. Active downloads: 2
[log] TestOutput -> Fetch completed. Active downloads: 1
[log] TestOutput -> Fetch completed. Active downloads: 0
Exited with 0
[log] WASM EXIT 0
Browser has been disconnected
    Wasm.Build.Tests.MaxParallelDownloadsTests.NeverFetchMoreThanMaxAllowed(config: Release, maxParallelDownloads: "4") [FINISHED] Time: 23.5878307s

@pavelsavara pavelsavara marked this pull request as ready for review March 2, 2026 10:53
Copilot AI review requested due to automatic review settings March 2, 2026 10:53
@pavelsavara pavelsavara requested a review from lewing as a code owner March 2, 2026 10:53
@pavelsavara pavelsavara changed the title [browser] throttling [browser][coreCLR] throttling Mar 2, 2026
@pavelsavara pavelsavara changed the title [browser][coreCLR] throttling [browser][coreCLR] throttling + WBT Mar 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.

Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor improvements.

@maraf
Copy link
Member

maraf commented Mar 2, 2026

+1 on Ilona's comments

@pavelsavara
Copy link
Member Author

/ba-g bad exit infra failures

@pavelsavara pavelsavara merged commit 12dbdb7 into dotnet:main Mar 2, 2026
169 of 173 checks passed
@pavelsavara pavelsavara deleted the improve_throttling branch March 2, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[coreclr] Max parallel downloads exceeds the maximum

4 participants