Skip to content

[tracking] Experimental WebAssembly multithreading support #68162

Open
@lambdageek

Description

@lambdageek

This is a tracking issue for adding experimental support for WebAssembly multi-threading to the browser-wasm runtime pack.

High Level Goals

  • The threading runtime should be distributed in the same browser-wasm runtime pack The threading runtime is in a separate .multithread. runtime pack variant. The WASM SDK chooses the correct runtime pack variant based on project properties.
  • Threading should be opt-in only
  • The wasm bindings and runtime are thread-safe and co-op GC aware

Completed in .NET 7 RC2

The wasm-experimental workload supports threading using <WasmEnableThreads>true</WasmEnableThreads> in interp and AOT configurations when using the wasmbrowser workload. Blazor does not support threading in .NET 7

Tracking

SDK:

CI testing:

  • Need a way to skip tests on single threaded / multi-threaded wasm configs.
  • Add tests. (src/libraries). Maybe add some convenient way to add ProjectReferences to the multi-threaded ref assemblies (the roll-up Microsoft.NET.WebAssembly.Threading.proj doesn't seem to work) and run the normal runtime tests.

Libraries and Interop:

Runtime and codegen:

Issues:

Done

On the branch:

  • put all modifications under conditionals
    • The runtime build should be under /p:WasmEnableThreads=true
    • ref assemblies should use FeatureWasmThreads in project files and FEATURE_WASM_THREADS in C# code to conditionally include [UnsupportedOSPlatform("browser")] guards around multi-threading APIs, and include the ref assembly in Microsoft.NET.WebAssembly.Threading
    • CoreLib uses FeatureWasmThreads and FEATURE_WASM_THREADS to define System.Thread.IsThreadStartSupported. All other code should check System.Thread.IsThreadStartSupported to throw a PNSE. There should not be [UnsupportedOSPlatform("browser")] guards in CoreLib
    • EventPipe and diagnostics should use FeatureWasmPerfTracing and FEATURE_WASM_PERFTRACING (and a constant?).
  • Add separate browser-mt and browser-mt-eventpipe samples.
  • Land the branch changes in main

In .NET 7 RC2

In .NET 8

...

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-VM-threading-monoos-browserBrowser variant of arch-wasmtrackingThis issue is tracking the completion of other related issues.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions