Repository navigation
[browser][coreclr] Prototype dedicated worker runtime hosting - #136364
Draft
pavelsavara wants to merge 12 commits into
Draft
pavelsavara wants to merge 12 commits into
pavelsavara wants to merge 12 commits into
Conversation
Forward entry assembly names and arguments, distinguish runMain from runMainAndExit, and wait for runtime shutdown before terminating workers. Correlate command completions to avoid races between Main and exit. Clean up workers after startup failures and timeouts, reject pending commands on worker failure, and add focused lifecycle regression tests. Update the browser sample and proxy API documentation, and move development notes out of the repository. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Include the runtime-owned shared memory in the ready handshake and initialize internal UI views without enabling public heap APIs. Reject missing or non-shared memory during startup. Add regression coverage for shared heap round trips, growth, invalid handshakes, and scratch cleanup. Validate real allocator growth and bidirectional access in the browser. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 23, 2026
Register UI functions through metadata and route synchronous Int32 imports through shared WASM argument frames. Reuse the worker's existing binder, result converters, and managed exception marshaling. Service imports while managed execution runs on the worker, reclaim ring slots after completion, and preserve ST null/undefined result behavior. Exercise DOM calls, JSException recovery, and queue wraparound in the sample and add focused transport regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Discover exports asynchronously, then dispatch Int32 calls through shared frames while the UI services synchronous imports. Reuse the worker's native binder and preserve primitive returns, aliases, and microtask ordering. Reclaim frames after failures, dispose managed error proxies, and publish worker failure state independently of queued UI error events. Reject stale signaling protocols and unsupported nested calls explicitly. Add regression coverage and exercise export/import calls in the browser sample without converting synchronous exports into Promise-returning APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pump nested exports while a worker import is waiting. Separate dispatch queues from active call slots so outer frames remain owned while nested and sibling calls execute, and retain independent per-call error payloads. Preserve ST microtask ordering, report capacity exhaustion explicitly, and keep completion IDs within the signed 32-bit wire representation. Add real worker-thread regression coverage, nested C# browser scenarios, and recovery checks for both import and export capacity limits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve synchronous call prefixes while routing Task completion through messages. Release shared frames after initial invocation, retain native Task ownership, and reject pending operations on worker exit or failure. Support Int32 Task exports and native-Promise UI imports. Reject custom thenables explicitly rather than permitting unsafe inline completion. Cover concurrent calls, lifecycle cleanup, and completion-ID rollover. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep runtime-pack memory non-shared and emit bounded Browser R2R memory imports, preserving the existing WASI contract. Stage app-owned shared native and R2R copies before fingerprinting rather than modifying the pack. Replace the unsafe memory patcher with bounded parsing and explicit errors. Cover source preservation, incremental memory-mode changes, asset integrity, and packaged SDK build/publish/native-relink startup in Chrome. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add an explicit worker mode and UI bootstrap to the library test harness. Exercise realm identity, synchronous nesting, scalar Task calls, concurrency, and error recovery with the same assertions on the ordinary runtime. Allow nested exports while runMainAndExit is executing managed Main, and preserve stdout forwarding when diagnostics installs its console proxy. Verify XHarness receives results and finishes worker tests through the UI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extend synchronous and Task calls to Int32/String argument and result combinations. Keep native marshaling and transient UTF16 allocation on the runtime worker, using explicit allocation and release handshakes for UI copies. Validate range and ownership, preserve native converter behavior, refresh views after native memory growth, and acknowledge allocation failures before reclaiming slots. Cover strings, nesting, concurrent Tasks, and cleanup in transport tests and the worker/ordinary library subset. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 28, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prototype dedicated web-worker hosting for Browser/CoreCLR through
dotnet.withWorker().create(). Managed execution runs on the worker; synchronous exports still block the UI caller to preserve the ST calling contract.runMainAndExit()and preserve stdout/stderr forwarding after the console proxy is installed.Current prototype scope
runMain(),runMainAndExit(),exit(), configuration, and build informationsetModuleImports()for one Int32 argument and an Int32 or native-Promise Int32 result; register each module once before managed executiongetAssemblyExports()discovery followed by synchronous Int32-to-Int32 calls or Int32-to-Task calls; synchronous signatures do not gain Promise wrappersWasmEnableSharedMemory=truestages app-owned shared assets; ordinary apps retain non-shared pack assetsWasmTestWithWorker=trueselects worker mode; 18 new cross-realm scalar cases pass in worker and ordinary ChromeStartup, lifecycle command parameters, registration metadata, and export discovery use messages. Synchronous interop requests, argument frames, and completion signals use shared memory. Managed execution and allocation remain worker-owned.
Draft scope and limitations
This remains an incomplete prototype, not a merge-ready feature:
System.Runtime.InteropServices.JavaScript.Testssuite has not passed in worker mode. Only the new 18-case scalar subset in that assembly is verified; broader types, existing helper migration, object identity, callbacks and GC/lifetime stress remain.worker-src, resource-loader/configuration callbacks and wider browser-engine coverage remain merge-readiness work. Fingerprinted loader startup is covered by the targeted packaged-SDK tests, not every hosting combination.Validation
Local validation on Windows with Debug Browser/CoreCLR, through 2026-10-27. Latest runtime build, 52 Node tests, TypeScript and targeted lint passed. XHarness verified 18/18 scalar library tests in worker mode and 18/18 on the ordinary runtime, with zero skipped cases.
src\native, passed all 52 tests:src\native, passed:git diff --checkbefore committing.Opt-in assets and library harness
System.Security.Cryptography.Pkcs8.0.1 dependency:TestUsingWorkloads=false, not the installed-workload path:Chrome / Playwright
Worker sample tests used a separately running server with COOP/COEP headers and browser caching disabled. Ordinary compatibility was also verified on a server without isolation headers.
mallocgrew memory from 70,385,664 to 136,773,632 bytes. Old data remained intact, UI views refreshed, and scratch allocations were freed on success and intentional failure.42, managed exceptions, UI exceptions, recovery after errors, and STnull/undefinedresult behavior.before,import,afteruntil the synchronous export returned, thenbefore,import,after,microtaskafter yielding. The spin loop did not pump arbitrary Promise continuations.before,import:3,import:2,import:1,import:0,after, then microtasks3,2,1,0only after yielding, matching the non-worker ST sample.withWorker(), creating no worker.Selected regression cases were also verified failing before their fixes, including missing heap sharing, scalar import/export support, completion/exit races, missing nested-call support, completion-before-wait behavior, signed completion-ID rollover, stale-protocol acceptance, and the M5 Task-prefix case against the published M4 export client. Nine formatting findings from an exploratory lint run on the pre-existing
.mjstest runner were confirmed present in the baseline and left outside these changes.Note
This pull request description and portions of the code were generated with GitHub Copilot.