diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
index 4ee41e222530b..31d7b385e0d4a 100644
--- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
+++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
@@ -112,7 +112,7 @@ jobs:
- browser_wasm
#- browser_wasm_win
nameSuffix: _Threading_Smoke
- extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:_WasmPThreadPoolSize=8 /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
+ extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:_WasmPThreadPoolSize=8 /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
shouldRunSmokeOnly: true
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
@@ -128,7 +128,7 @@ jobs:
- browser_wasm
#- browser_wasm_win
nameSuffix: _Threading
- extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:_WasmPThreadPoolSize=8 /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
+ extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:_WasmPThreadPoolSize=8 /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
# Always run for runtime-wasm because tests are not run in runtime
@@ -137,29 +137,9 @@ jobs:
# NOTE - Since threading is experimental, we don't want to block mainline work
shouldContinueOnError: true
scenarios:
- - normal
- WasmTestOnBrowser
- - WasmTestOnNodeJS
-
- # Library tests with internal threads only
- - template: /eng/pipelines/common/templates/wasm-library-tests.yml
- parameters:
- platforms:
- - browser_wasm
- #- browser_wasm_win
- nameSuffix: _Threading_PerfTracing
- extraBuildArgs: /p:MonoWasmBuildVariant=perftrace /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
- isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
- isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }}
- # Always run for runtime-wasm because tests are not run in runtime
- alwaysRun: ${{ parameters.isWasmOnlyBuild }}
+ #- WasmTestOnNodeJS - this is not supported yet, https://github.com/dotnet/runtime/issues/85592
- # NOTE - Since threading is experimental, we don't want to block mainline work
- shouldContinueOnError: true
- scenarios:
- - normal
- - WasmTestOnBrowser
- - WasmTestOnNodeJS
# EAT Library tests - only run on linux
- template: /eng/pipelines/common/templates/wasm-library-aot-tests.yml
diff --git a/eng/pipelines/mono/templates/workloads-build.yml b/eng/pipelines/mono/templates/workloads-build.yml
index fb53430c03791..b962dcb65d178 100644
--- a/eng/pipelines/mono/templates/workloads-build.yml
+++ b/eng/pipelines/mono/templates/workloads-build.yml
@@ -55,12 +55,10 @@ jobs:
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.android-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.browser-wasm*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm*.nupkg
- IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.perftrace.browser-wasm*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.ios-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.iossimulator-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.maccatalyst-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm*.nupkg
- IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.perftrace.browser-wasm*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.tvos-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.tvossimulator-*.nupkg
IntermediateArtifacts/MonoRuntimePacks/Shipping/Microsoft.NETCore.App.Runtime.Mono.wasi-wasm*.nupkg
diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml
index 7cae3a51ee9da..9aa97b9034a3c 100644
--- a/eng/pipelines/runtime-official.yml
+++ b/eng/pipelines/runtime-official.yml
@@ -180,22 +180,6 @@ extends:
extraStepsParameters:
name: MonoRuntimePacks
- - template: /eng/pipelines/common/platform-matrix.yml
- parameters:
- jobTemplate: /eng/pipelines/common/global-build-job.yml
- buildConfig: release
- runtimeFlavor: mono
- platforms:
- - browser_wasm
- jobParameters:
- buildArgs: -s mono+libs+host+packs -c $(_BuildConfig) /p:MonoWasmBuildVariant=perftrace /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
- nameSuffix: AllSubsets_Mono_perftrace
- isOfficialBuild: ${{ variables.isOfficialBuild }}
- runtimeVariant: perftrace
- extraStepsTemplate: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
- extraStepsParameters:
- name: MonoRuntimePacks
-
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml
index 784d3f86da5d6..4731612916c65 100644
--- a/eng/pipelines/runtime.yml
+++ b/eng/pipelines/runtime.yml
@@ -505,14 +505,6 @@ extends:
scenarios:
- WasmTestOnBrowser
- - template: /eng/pipelines/common/templates/wasm-build-only.yml
- parameters:
- platforms:
- - browser_wasm
- nameSuffix: _Threading_PerfTracing
- extraBuildArgs: /p:MonoWasmBuildVariant=perftrace /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
- alwaysRun: ${{ variables.isRollingBuild }}
-
# WASI/WASM
- template: /eng/pipelines/common/templates/wasm-library-tests.yml
diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets
index f2ff4716ae511..e48831cc61d6a 100644
--- a/eng/testing/tests.browser.targets
+++ b/eng/testing/tests.browser.targets
@@ -96,6 +96,10 @@
<_AppArgs Condition="'$(WasmTestAppArgs)' != ''">$(_AppArgs) $(WasmTestAppArgs)
$(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=1
+
+ $(WasmXHarnessMonoArgs) --no-memory-snapshot
+
+ $(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true
@@ -104,7 +108,7 @@
<_XHarnessArgs Condition="'$(IsFunctionalTest)' == 'true'" >$(_XHarnessArgs) --expected-exit-code=$(ExpectedExitCode)
<_XHarnessArgs Condition="'$(WasmXHarnessArgs)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgs)
- <_XHarnessArgs Condition="('$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true') and '$(_XHarnessArs.Contains("--web-server-use-cop")' != 'true'">$(_XHarnessArgs) --web-server-use-cop
+ <_XHarnessArgs Condition="'$(MonoWasmBuildVariant)' == 'multithread' and '$(_XHarnessArs.Contains("--web-server-use-cop")' != 'true'">$(_XHarnessArgs) --web-server-use-cop
<_XHarnessArgs >$(_XHarnessArgs) -s dotnet.native.js.symbols
<_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbol-patterns wasm-symbol-patterns.txt
<_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbolicator WasmSymbolicator.dll,Microsoft.WebAssembly.Internal.SymbolicatorWrapperForXHarness
@@ -288,7 +292,6 @@
<_DefaultBuildVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread'">.multithread.
- <_DefaultBuildVariant Condition="'$(MonoWasmBuildVariant)' == 'perftrace'">.perftrace.
<_DefaultBuildVariant Condition="'$(_DefaultBuildVariant)' == ''">.
<_DefaultRuntimePackNuGetPath>$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono$(_DefaultBuildVariant)$(RuntimeIdentifier).$(PackageVersionForWorkloadManifests).nupkg
@@ -305,7 +308,6 @@
<_BuildVariants Include="multithread" Condition="'$(_DefaultBuildVariant)' != '.multithread.'" />
- <_BuildVariants Include="perftrace" Condition="'$(_DefaultBuildVariant)' != '.perftrace.'" />
<_NuGetsToBuild Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.%(_BuildVariants.Identity).$(RuntimeIdentifier).$(PackageVersionForWorkloadManifests).nupkg"
Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj"
diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
index 88ab461e49dce..0d51391bd956b 100644
--- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
+++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
@@ -116,7 +116,7 @@ public static bool IsPrivilegedProcess
public static bool FileCreateCaseSensitive => IsCaseSensitiveOS;
#endif
- public static bool IsThreadingSupported => !IsBrowser && !IsWasi;
+ public static bool IsThreadingSupported => !IsWasi && IsEnvironmentVariableTrue("IsBrowserThreadingSupported");
public static bool IsBinaryFormatterSupported => IsNotMobile && !IsNativeAot;
public static bool IsStartingProcessesSupported => !IsiOS && !IstvOS;
diff --git a/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj b/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj
index c571f7b37eb65..d85325676cd5c 100644
--- a/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj
+++ b/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj
@@ -4,8 +4,7 @@
true
-
+
diff --git a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj
index f33752cfa88af..7e0202c10b9d7 100644
--- a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj
+++ b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj
@@ -10,7 +10,7 @@
$(NoWarn);0809;0618;CS8614;CS3015
SilverlightPlatform
true
- true
+ true
true
$(DefineConstants);FEATURE_WASM_PERFTRACING
$(DefineConstants);FEATURE_WASM_THREADS
diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj
index a013e7ba3d969..d5723a09d9b9f 100644
--- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj
+++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj
@@ -1,6 +1,7 @@
$(NetCoreAppCurrent)
+ true
$(DefineConstants);FEATURE_WASM_THREADS
diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj
index f6fa4f54e86b0..0db1894960572 100644
--- a/src/libraries/tests.proj
+++ b/src/libraries/tests.proj
@@ -52,10 +52,6 @@
-
-
-
-
@@ -375,13 +371,6 @@
-
-
-
-
-
-
-
diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
index de20a6fe30e69..2dc26dbe71fdc 100644
--- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -121,7 +121,7 @@
true
true
- true
+ true
true
true
true
diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in
index b76584ce4dd37..4290ae974ed5e 100644
--- a/src/mono/cmake/config.h.in
+++ b/src/mono/cmake/config.h.in
@@ -299,9 +299,6 @@
/* Disable Threads */
#cmakedefine DISABLE_THREADS 1
-/* Disable user thread creation on WebAssembly */
-#cmakedefine DISABLE_WASM_USER_THREADS 1
-
/* Disable MONO_LOG_DEST */
#cmakedefine DISABLE_LOG_DEST
diff --git a/src/mono/cmake/options.cmake b/src/mono/cmake/options.cmake
index 202a578db4fc4..f5af034cc919c 100644
--- a/src/mono/cmake/options.cmake
+++ b/src/mono/cmake/options.cmake
@@ -56,7 +56,6 @@ option (ENABLE_OVERRIDABLE_ALLOCATORS "Enable overridable allocator support")
option (ENABLE_SIGALTSTACK "Enable support for using sigaltstack for SIGSEGV and stack overflow handling, this doesn't work on some platforms")
option (USE_MALLOC_FOR_MEMPOOLS "Use malloc for each single mempool allocation, so tools like Valgrind can run better")
option (STATIC_COMPONENTS "Compile mono runtime components as static (not dynamic) libraries")
-option (DISABLE_WASM_USER_THREADS "Disable creation of user managed threads on WebAssembly, only allow runtime internal managed and native threads")
option (ENABLE_WEBCIL "Enable the WebCIL loader")
set (MONO_GC "sgen" CACHE STRING "Garbage collector implementation (sgen or boehm). Default: sgen")
diff --git a/src/mono/mono.proj b/src/mono/mono.proj
index 8b412b3369ef0..3947c7b4b4eab 100644
--- a/src/mono/mono.proj
+++ b/src/mono/mono.proj
@@ -9,7 +9,6 @@
- MonoVerboseBuild - enable verbose build
- MonoThreadSuspend - coop,hybrid,preemptive - default thread suspend mode
- MonoWasmThreads - build runtime with threading support for wasm
- - MonoWasmThreadsNoUser - build runtime with threading support for wasm, but with only internal utility threads (MonoWasmThreads must be defined too)
-->
@@ -54,8 +53,7 @@
$([MSBuild]::NormalizeDirectory('$(RepositoryEngineeringDir)', 'common'))
$([MSBuild]::NormalizePath('$(RepositoryEngineeringCommonDir)', 'cross', 'toolchain.cmake'))
false
- true
- true
+ true
true
@@ -417,7 +415,6 @@
<_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest
<_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages
<_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads
- <_MonoMinimal Condition="'$(MonoWasmThreadsNoUser)' == 'true'">$(_MonoMinimal),wasm_user_threads
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/>
diff --git a/src/mono/mono/mini/mini-wasm.c b/src/mono/mono/mini/mini-wasm.c
index cab202a1fa326..21174bec0d860 100644
--- a/src/mono/mono/mini/mini-wasm.c
+++ b/src/mono/mono/mini/mini-wasm.c
@@ -586,7 +586,11 @@ mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo
EMSCRIPTEN_KEEPALIVE void
mono_wasm_execute_timer (void)
{
- g_assert (timer_handler);
+ // callback could be null if timer was never used by the application, but only by prevent_timer_throttling_tick()
+ if (timer_handler==NULL) {
+ return;
+ }
+
background_job_cb cb = timer_handler;
cb ();
}
diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
index aabee7e79f819..c350427870370 100644
--- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
+++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
@@ -19,7 +19,6 @@
"packs": [
"Microsoft.NET.Runtime.WebAssembly.Templates",
"Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm",
- "Microsoft.NETCore.App.Runtime.Mono.perftrace.browser-wasm"
],
"extends": [ "wasm-tools" ],
"platforms": [ "win-x64", "win-arm64", "linux-x64", "osx-x64", "osx-arm64" ]
@@ -376,10 +375,6 @@
"kind": "framework",
"version": "${PackageVersion}"
},
- "Microsoft.NETCore.App.Runtime.Mono.perftrace.browser-wasm" : {
- "kind": "framework",
- "version": "${PackageVersion}"
- },
"Microsoft.NETCore.App.Runtime.Mono.wasi-wasm" : {
"kind": "framework",
"version": "${PackageVersion}"
diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
index a240a5ac4b91f..f0422f40fce07 100644
--- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
+++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
@@ -149,7 +149,6 @@
$(_MonoWorkloadRuntimePackPackageVersion)
Microsoft.NETCore.App.Runtime.Mono.multithread.**RID**
- Microsoft.NETCore.App.Runtime.Mono.perftrace.**RID**
$(_KnownWebAssemblySdkPackVersion)
diff --git a/src/mono/sample/wasm/DefaultBrowserSample.targets b/src/mono/sample/wasm/DefaultBrowserSample.targets
index ce72d3a8a960f..67ca72e8c6c31 100644
--- a/src/mono/sample/wasm/DefaultBrowserSample.targets
+++ b/src/mono/sample/wasm/DefaultBrowserSample.targets
@@ -6,6 +6,7 @@
-1
true
+ $(WasmXHarnessArgs) --web-server-use-cop
$(ExecXHarnessCmd) wasm test-browser --app=. --browser=Chrome $(XHarnessBrowserPathArg) $(WasmXHarnessArgs) --html-file=index.html --output-directory=$(XHarnessOutput) -- $(MSBuildProjectName).dll
diff --git a/src/mono/sample/wasm/Directory.Build.props b/src/mono/sample/wasm/Directory.Build.props
index a5af908c5fef0..b45ae6b731f8c 100644
--- a/src/mono/sample/wasm/Directory.Build.props
+++ b/src/mono/sample/wasm/Directory.Build.props
@@ -15,7 +15,6 @@
bin
$(MSBuildProjectDirectory)\bin\$(Configuration)\AppBundle\
- $(WasmXHarnessArgs) --web-server-use-cop
false
diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets
index 88aceecfaed96..b61806bd837df 100644
--- a/src/mono/sample/wasm/Directory.Build.targets
+++ b/src/mono/sample/wasm/Directory.Build.targets
@@ -9,9 +9,7 @@
$([MSBuild]::NormalizePath('$(WasmAppDir)', '$(RunScriptOutputName)'))
- <_MonoWasmThreads Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">true
- $(WasmXHarnessArgs) --web-server-use-cop
- <_ServeHeaders Condition="'$(_MonoWasmThreads)' == 'true'">$(_ServeHeaders) -h Cross-Origin-Embedder-Policy:require-corp -h Cross-Origin-Opener-Policy:same-origin
+ <_ServeHeaders Condition="'$(WasmEnableThreads)' == 'true'">$(_ServeHeaders) -h Cross-Origin-Embedder-Policy:require-corp -h Cross-Origin-Opener-Policy:same-origin
<_ServeMimeTypes>$(_ServeMimeTypes) --mime .wasm=application/wasm
diff --git a/src/mono/sample/wasm/browser-eventpipe/Program.cs b/src/mono/sample/wasm/browser-eventpipe/Program.cs
index 65248020f5d3d..e04922cf95558 100644
--- a/src/mono/sample/wasm/browser-eventpipe/Program.cs
+++ b/src/mono/sample/wasm/browser-eventpipe/Program.cs
@@ -121,10 +121,13 @@ public static async Task StartAsyncWork(int N)
b = recursiveFib (N);
WasmHelloEventSource.Instance.StopFib(N, b.ToString());
iterations++;
+ Console.WriteLine ("ping1");
if (ct.IsCancellationRequested)
break;
}
+ Console.WriteLine ("stopping");
long expected = fastFib(N);
+ Console.WriteLine ("stopping2");
if (expected == b)
return (double)b;
else {
diff --git a/src/mono/sample/wasm/browser-eventpipe/README.md b/src/mono/sample/wasm/browser-eventpipe/README.md
index 41e10bc7b8bbb..bbbf5d872a834 100644
--- a/src/mono/sample/wasm/browser-eventpipe/README.md
+++ b/src/mono/sample/wasm/browser-eventpipe/README.md
@@ -1,10 +1,10 @@
[see also](../../../wasm/runtime/diagnostics/README.md)
-To be able to run this sample you need to build the runtime with `/p:WasmEnablePerfTracing=true` and use Chrome browser
+To be able to run this sample you need to build the runtime with `/p:MonoWasmBuildVariant=multithread` and use Chrome browser
# Testing with mock
-Build the runtime with `/p:MonoWasmBuildVariant=perftrace /p:MonoDiagnosticsMock=true`
+Build the runtime with `/p:MonoWasmBuildVariant=multithread /p:MonoDiagnosticsMock=true`
Run this test with `/p:MonoDiagnosticsMock=true`
It will inject file [mock.js](./mock.js) into the worker thread, which is mocking the `dotnet trace` tool.
@@ -17,7 +17,7 @@ dotnet trace convert --format Speedscope c:\Downloads\trace.1665653486202.nettra
# Testing with dotnet trace tool
-Build the runtime with `/p:MonoWasmBuildVariant=perftrace`
+Build the runtime with `/p:MonoWasmBuildVariant=multithread`
Build a version of dsrouter with WebSockets support (versions from upstream that target net6.0 or later have the requisite support, see https://github.com/dotnet/diagnostics/blob/main/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj)
In console #1 start dsrouter
diff --git a/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj b/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
index bf56a93391a17..f8ff793e46707 100644
--- a/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
+++ b/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
@@ -1,16 +1,13 @@
-
true
true
+ true
true
-
$(NoWarn);CA2007
-
-
-
true
+
diff --git a/src/mono/sample/wasm/browser-eventpipe/main.js b/src/mono/sample/wasm/browser-eventpipe/main.js
index 2bf5dc8d9ff9a..683c076b579dd 100644
--- a/src/mono/sample/wasm/browser-eventpipe/main.js
+++ b/src/mono/sample/wasm/browser-eventpipe/main.js
@@ -66,6 +66,11 @@ async function main() {
btn.style.backgroundColor = "rgb(192,255,192)";
btn.onclick = () => doWork(exports.Sample.Test.StartAsyncWork, exports.Sample.Test.StopWork, exports.Sample.Test.GetIterationsDone);
+ if (INTERNAL.diagnosticServerThread === undefined) {
+ console.warn("please recompile runtime with /p:MonoWasmBuildVariant=multithread /p:MonoDiagnosticsMock=true" + event.type)
+ return;
+ }
+
INTERNAL.diagnosticServerThread.port.addEventListener("message", (event) => {
console.warn("diagnosticServerThread" + event.type)
diff --git a/src/mono/sample/wasm/browser-threads-minimal/Wasm.Browser.Threads.Minimal.Sample.csproj b/src/mono/sample/wasm/browser-threads-minimal/Wasm.Browser.Threads.Minimal.Sample.csproj
index defce7521ac7f..bd8644d2fefd3 100644
--- a/src/mono/sample/wasm/browser-threads-minimal/Wasm.Browser.Threads.Minimal.Sample.csproj
+++ b/src/mono/sample/wasm/browser-threads-minimal/Wasm.Browser.Threads.Minimal.Sample.csproj
@@ -1,8 +1,8 @@
-
true
+
diff --git a/src/mono/sample/wasm/browser-threads/Program.cs b/src/mono/sample/wasm/browser-threads/Program.cs
index 8fb461a854676..148a002dfe1ed 100644
--- a/src/mono/sample/wasm/browser-threads/Program.cs
+++ b/src/mono/sample/wasm/browser-threads/Program.cs
@@ -75,7 +75,7 @@ public void Start()
public void Run()
{
- Sample.Test.ConsoleLog("Hello from ManagedThreadId " + Thread.CurrentThread.ManagedThreadId);
+ Console.WriteLine("Hello from ManagedThreadId " + Thread.CurrentThread.ManagedThreadId);
long result = Fib(UpTo);
if (result < (long)int.MaxValue)
_tcs.SetResult((int)result);
diff --git a/src/mono/sample/wasm/browser-threads/Wasm.Browser.Threads.Sample.csproj b/src/mono/sample/wasm/browser-threads/Wasm.Browser.Threads.Sample.csproj
index f9c81f4b40e71..629f181dcd61c 100644
--- a/src/mono/sample/wasm/browser-threads/Wasm.Browser.Threads.Sample.csproj
+++ b/src/mono/sample/wasm/browser-threads/Wasm.Browser.Threads.Sample.csproj
@@ -1,8 +1,8 @@
-
true
+
diff --git a/src/mono/sample/wasm/simple-server/Program.cs b/src/mono/sample/wasm/simple-server/Program.cs
index 6d1148f9d2251..64e6e105c31b7 100644
--- a/src/mono/sample/wasm/simple-server/Program.cs
+++ b/src/mono/sample/wasm/simple-server/Program.cs
@@ -281,6 +281,8 @@ private async void ServeAsync(HttpListenerContext context)
context.Response.ContentLength64 = buffer.Length;
context.Response.AppendHeader("cache-control", "public, max-age=31536000");
+ context.Response.AppendHeader("Cross-Origin-Embedder-Policy", "require-corp");
+ context.Response.AppendHeader("Cross-Origin-Opener-Policy", "same-origin");
// test download re-try
if (url.Query.Contains("testAbort"))
diff --git a/src/mono/wasi/build/WasiApp.Native.targets b/src/mono/wasi/build/WasiApp.Native.targets
index 75016fede60e7..daeb8515c1388 100644
--- a/src/mono/wasi/build/WasiApp.Native.targets
+++ b/src/mono/wasi/build/WasiApp.Native.targets
@@ -518,7 +518,7 @@
-
+
diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt
index 08bb59b06684a..9690f6ab1abfc 100644
--- a/src/mono/wasi/runtime/CMakeLists.txt
+++ b/src/mono/wasi/runtime/CMakeLists.txt
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.14.5)
project(mono-wasi-runtime C)
option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON)
-option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF)
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
add_executable(dotnet driver.c main.c pinvoke.c stubs.c synthetic-pthread.c)
diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj
index 69aad8fae6825..e8742d36f8345 100644
--- a/src/mono/wasi/wasi.proj
+++ b/src/mono/wasi/wasi.proj
@@ -224,7 +224,6 @@
$(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/'))"
$(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd"
$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0
- $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1
call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" wasm && $(CMakeBuildRuntimeConfigureCmd)
-v
diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets
index f1050ca67512f..fe557f03675d6 100644
--- a/src/mono/wasm/build/WasmApp.Native.targets
+++ b/src/mono/wasm/build/WasmApp.Native.targets
@@ -597,7 +597,7 @@
-
+
diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets
index 50b4cb9ea4050..ad7749b6024ec 100644
--- a/src/mono/wasm/build/WasmApp.targets
+++ b/src/mono/wasm/build/WasmApp.targets
@@ -371,7 +371,7 @@
- <_WasmAppIncludeThreadsWorker Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true'">true
+ <_WasmAppIncludeThreadsWorker Condition="'$(WasmEnableThreads)' == 'true'">true
<_WasmPThreadPoolSize Condition="'$(_WasmPThreadPoolSize)' == ''">-1
diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj
index e9d4067311a0e..210778d941ec1 100644
--- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj
+++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj
@@ -8,7 +8,7 @@
true
library
true
- <_WasmPThreadPoolSize Condition="'$(WasmEnableThreads)'=='true'">10
+ <_WasmPThreadPoolSize Condition="'$(MonoWasmBuildVariant)' == 'multithread'">10
true
diff --git a/src/mono/wasm/runtime/CMakeLists.txt b/src/mono/wasm/runtime/CMakeLists.txt
index bb311e32b6e27..b44de7e4adfb0 100644
--- a/src/mono/wasm/runtime/CMakeLists.txt
+++ b/src/mono/wasm/runtime/CMakeLists.txt
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.14.5)
project(mono-wasm-runtime C)
option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON)
-option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF)
option(DISABLE_LEGACY_JS_INTEROP "defined if the build does not support legacy JavaScript interop" OFF)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
diff --git a/src/mono/wasm/runtime/diagnostics/index.ts b/src/mono/wasm/runtime/diagnostics/index.ts
index ee92751818b97..2b973f2f11aaa 100644
--- a/src/mono/wasm/runtime/diagnostics/index.ts
+++ b/src/mono/wasm/runtime/diagnostics/index.ts
@@ -11,6 +11,7 @@ import type { VoidPtr } from "../types/emscripten";
import { getController, startDiagnosticServer } from "./browser/controller";
import * as memory from "../memory";
import { mono_log_warn } from "../logging";
+import { runtimeHelpers } from "../globals";
// called from C on the main thread
@@ -80,7 +81,7 @@ function boolsyOption(x: string | boolean): boolean {
/// * DOTNET_DiagnosticPorts
///
function diagnostic_options_from_environment(): DiagnosticOptions | null {
- const val = memory.getEnv("DOTNET_DiagnosticPorts");
+ const val = runtimeHelpers.config.environmentVariables ? runtimeHelpers.config.environmentVariables["DOTNET_DiagnosticPorts"] : undefined;
if (is_nullish(val))
return null;
// TODO: consider also parsing the DOTNET_EnableEventPipe and DOTNET_EventPipeOutputPath, DOTNET_EvnetPipeConfig variables
diff --git a/src/mono/wasm/runtime/startup.ts b/src/mono/wasm/runtime/startup.ts
index 978bbb55025ec..7faea31a50e53 100644
--- a/src/mono/wasm/runtime/startup.ts
+++ b/src/mono/wasm/runtime/startup.ts
@@ -232,10 +232,10 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) {
await wait_for_all_assets();
- // Diagnostics early are not supported with memory snapshot. See below how we enable them later.
+ // Threads early are not supported with memory snapshot. See below how we enable them later.
// Please disable startupMemoryCache in order to be able to diagnose or pause runtime startup.
if (MonoWasmThreads && !runtimeHelpers.config.startupMemoryCache) {
- await mono_wasm_init_diagnostics();
+ await mono_wasm_init_threads();
}
// load runtime and apply environment settings (if necessary)
@@ -251,14 +251,8 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) {
return;
}
- if (MonoWasmThreads) {
- if (runtimeHelpers.config.startupMemoryCache) {
- // we could enable diagnostics after the snapshot is taken
- await mono_wasm_init_diagnostics();
- }
- const tid = getBrowserThreadID();
- mono_set_thread_id(`0x${tid.toString(16)}-main`);
- await instantiateWasmPThreadWorkerPool();
+ if (MonoWasmThreads && runtimeHelpers.config.startupMemoryCache) {
+ await mono_wasm_init_threads();
}
bindings_init();
@@ -318,6 +312,15 @@ async function postRunAsync(userpostRun: (() => void)[]) {
runtimeHelpers.afterPostRun.promise_control.resolve();
}
+async function mono_wasm_init_threads() {
+ if (!MonoWasmThreads) {
+ return;
+ }
+ const tid = getBrowserThreadID();
+ mono_set_thread_id(`0x${tid.toString(16)}-main`);
+ await instantiateWasmPThreadWorkerPool();
+ await mono_wasm_init_diagnostics();
+}
function mono_wasm_pre_init_essential(isWorker: boolean): void {
if (!isWorker)
diff --git a/src/mono/wasm/runtime/wasm-config.h.in b/src/mono/wasm/runtime/wasm-config.h.in
index 88a9599eeba6d..ee9adc20600c7 100644
--- a/src/mono/wasm/runtime/wasm-config.h.in
+++ b/src/mono/wasm/runtime/wasm-config.h.in
@@ -7,9 +7,6 @@
/* Support for threads is disabled */
#cmakedefine DISABLE_THREADS
-/* Support for starting user threads is disabled */
-#cmakedefine DISABLE_WASM_USER_THREADS
-
/* Support for legacy JS interop is disabled */
#cmakedefine DISABLE_LEGACY_JS_INTEROP
diff --git a/src/mono/wasm/runtime/web-socket.ts b/src/mono/wasm/runtime/web-socket.ts
index 946d5045be6ad..9e16886eedbae 100644
--- a/src/mono/wasm/runtime/web-socket.ts
+++ b/src/mono/wasm/runtime/web-socket.ts
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+import MonoWasmThreads from "consts:monoWasmThreads";
+
import { prevent_timer_throttling } from "./scheduling";
import { Queue } from "./queue";
import { createPromiseController } from "./globals";
@@ -321,7 +323,11 @@ function _mono_wasm_web_socket_send_buffering(ws: WebSocketExtension, buffer_vie
else {
if (length !== 0) {
// we could use the un-pinned view, because it will be immediately used in ws.send()
- buffer = buffer_view;
+ if (MonoWasmThreads) {
+ buffer = buffer_view.slice(); // copy, because the provided ArrayBufferView value must not be shared.
+ } else {
+ buffer = buffer_view;
+ }
offset = length;
}
}
diff --git a/src/mono/wasm/threads.md b/src/mono/wasm/threads.md
index bf75f46137b6a..d5fc9e5e63f4a 100644
--- a/src/mono/wasm/threads.md
+++ b/src/mono/wasm/threads.md
@@ -4,15 +4,10 @@
Build the runtime with `/p:MonoWasmBuildVariant=multithread` to enable support for multi-threading.
-Build with `/p:MonoWasmBuildVariant=perftrace` to enable support for EventPipe diagnostics - this enabled threading, but only for "internal" utility threads. User code is not allowed to start threads.
-
-Do not combine these options, just turn on one or the other.
-
## Building sample apps ##
-Sample apps use the "public" properties `WasmEnableThreads` and `WasmEnablePerfTracing` to enable
-the relevant functionality. This also works with released versions of .NET 7 or later and the
-`wasmbrowser` template.
+Sample apps use the "public" properties `WasmEnableThreads` to enable the relevant functionality.
+This also works with released versions of .NET 7 or later and the `wasmbrowser` template.
## Libraries feature defines ##
@@ -56,10 +51,6 @@ In `src/mono/mono` and `src/mono/wasm` `DISABLE_THREADS` is defined for single-t
as mono's existing `-DENABLE_MINIMAL=threads` option). In multi-threaded builds, `DISABLE_THREADS`
is _not_ defined.
-For `WasmEnablePerfTracing`, `DISABLE_THREADS` is undefined (ie threading is enabled), but starting
-user threads is not supported and `DISABLE_WASM_USER_THREADS` is defined (ie there is a
-`-DENABLE_MINIMAL=wasm-user-threads` option)
-
Additionally, `__EMSCRIPTEN_THREADS__` is defined by emscripten if threading is enabled.
## Browser thread, main thread ##
diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj
index 7bc98cdff5152..55f4c6c0e7399 100644
--- a/src/mono/wasm/wasm.proj
+++ b/src/mono/wasm/wasm.proj
@@ -16,8 +16,7 @@
- true
- true
+ true
false
true
@@ -396,7 +395,6 @@
$(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/').Replace('\','/'))"
$(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd"
$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0
- $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1
$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_LEGACY_JS_INTEROP=1
$(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath)
diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj
index 92fa2ee3c5846..40ceef386732a 100644
--- a/src/native/libs/build-native.proj
+++ b/src/native/libs/build-native.proj
@@ -11,9 +11,9 @@
<_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)"
<_RuntimeVariant />
- <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">-threads
+ <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread'">-threads
<_UsePThreads />
- <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'"> usepthreads
+ <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread'"> usepthreads
<_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native
<_IcuDirArg Condition="'$(_IcuDir)' != ''"> icudir "$(_IcuDir)"
diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs
index 41722523d284d..ad445100ee741 100644
--- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs
+++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs
@@ -16,7 +16,6 @@ public class AssetsComputingHelper
{
"Microsoft.NETCore.App.Runtime.Mono.browser-wasm",
"Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm",
- "Microsoft.NETCore.App.Runtime.Mono.perftrace.browser-wasm",
};
private static readonly string[] dotnetJsSingleThreadNames = new[]