From 7028044eec7a0143d0b0f3af0eab3468d3cc1abe Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 19 Jun 2023 21:30:58 +0200 Subject: [PATCH 1/4] - rebased - removed perftrace runtime flavor - removed MonoWasmBuildVariant==perftrace - made IsThreadingSupported respect build flavor via IsBrowserThreadingSupported and --use-threads - removed most of event-pipe wasm sample - removed DISABLE_WASM_USER_THREADS and MonoWasmThreadsNoUser - fixed mono_wasm_execute_timer for WS without Main - added COOP into SimpleServer - fixed problem with SharedArrayBuffer in WS --- .../runtime-extra-platforms-wasm.yml | 24 +-- .../mono/templates/workloads-build.yml | 2 - eng/pipelines/runtime-official.yml | 16 -- eng/pipelines/runtime.yml | 8 - eng/testing/tests.browser.targets | 8 +- .../TestUtilities/System/PlatformDetection.cs | 2 +- .../src/System.Diagnostics.Tracing.csproj | 3 +- .../ref/System.Private.CoreLib.csproj | 2 +- src/libraries/tests.proj | 12 -- .../System.Private.CoreLib.csproj | 2 +- src/mono/cmake/config.h.in | 3 - src/mono/cmake/options.cmake | 1 - src/mono/mono.proj | 5 +- src/mono/mono/mini/mini-wasm.c | 6 +- .../WorkloadManifest.json.in | 5 - .../WorkloadManifest.targets.in | 8 - src/mono/sample/wasm/Directory.Build.props | 3 +- src/mono/sample/wasm/Directory.Build.targets | 2 +- .../sample/wasm/browser-eventpipe/Makefile | 13 -- .../sample/wasm/browser-eventpipe/Program.cs | 162 ------------------ .../Wasm.Browser.EventPipe.Sample.csproj | 49 ------ .../sample/wasm/browser-eventpipe/index.html | 22 --- .../sample/wasm/browser-eventpipe/main.js | 102 ----------- src/mono/sample/wasm/simple-server/Program.cs | 2 + src/mono/wasi/build/WasiApp.Native.targets | 2 +- src/mono/wasi/runtime/CMakeLists.txt | 1 - src/mono/wasi/wasi.proj | 1 - src/mono/wasm/build/WasmApp.Native.targets | 2 +- src/mono/wasm/build/WasmApp.targets | 2 +- .../tests/debugger-test/debugger-test.csproj | 2 +- src/mono/wasm/runtime/CMakeLists.txt | 1 - src/mono/wasm/runtime/wasm-config.h.in | 3 - src/mono/wasm/runtime/web-socket.ts | 8 +- src/mono/wasm/test-main.js | 2 + src/mono/wasm/threads.md | 13 +- src/mono/wasm/wasm.proj | 4 +- src/native/libs/build-native.proj | 4 +- .../AssetsComputingHelper.cs | 1 - 38 files changed, 40 insertions(+), 468 deletions(-) delete mode 100644 src/mono/sample/wasm/browser-eventpipe/Makefile delete mode 100644 src/mono/sample/wasm/browser-eventpipe/Program.cs delete mode 100644 src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj delete mode 100644 src/mono/sample/wasm/browser-eventpipe/index.html delete mode 100644 src/mono/sample/wasm/browser-eventpipe/main.js diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml index 4ee41e222530b..625e6c0e130c7 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml @@ -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 @@ -264,7 +244,7 @@ jobs: platforms: - Browser_wasm - Browser_wasm_win - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) nameSuffix: DebuggerTests_MultiThreaded alwaysRun: ${{ parameters.isWasmOnlyBuild }} isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }} 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..71968c3030aae 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) --use-threads @@ -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/tests.proj b/src/libraries/tests.proj index f6fa4f54e86b0..129556b394af8 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -54,11 +54,6 @@ - - - - - @@ -375,13 +370,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..e1de687de9e50 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) @@ -176,11 +175,4 @@ - - - - diff --git a/src/mono/sample/wasm/Directory.Build.props b/src/mono/sample/wasm/Directory.Build.props index a5af908c5fef0..57a456b3720e4 100644 --- a/src/mono/sample/wasm/Directory.Build.props +++ b/src/mono/sample/wasm/Directory.Build.props @@ -6,6 +6,7 @@ browser wasm browser-wasm + multithread $(NoWarn);IL2121 @@ -15,7 +16,7 @@ bin $(MSBuildProjectDirectory)\bin\$(Configuration)\AppBundle\ - $(WasmXHarnessArgs) --web-server-use-cop + $(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..4238580d7fb55 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -9,7 +9,7 @@ $([MSBuild]::NormalizePath('$(WasmAppDir)', '$(RunScriptOutputName)')) - <_MonoWasmThreads Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">true + <_MonoWasmThreads Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">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 diff --git a/src/mono/sample/wasm/browser-eventpipe/Makefile b/src/mono/sample/wasm/browser-eventpipe/Makefile deleted file mode 100644 index b029e47ddbd15..0000000000000 --- a/src/mono/sample/wasm/browser-eventpipe/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -TOP=../../../../.. - -include ../wasm.mk - -override MSBUILD_ARGS+=/p:WasmEnablePerfTracing=true - -ifneq ($(AOT),) -override MSBUILD_ARGS+=/p:RunAOTCompilation=true -endif - -PROJECT_NAME=Wasm.Browser.EventPipe.Sample.csproj - -run: run-browser diff --git a/src/mono/sample/wasm/browser-eventpipe/Program.cs b/src/mono/sample/wasm/browser-eventpipe/Program.cs deleted file mode 100644 index 65248020f5d3d..0000000000000 --- a/src/mono/sample/wasm/browser-eventpipe/Program.cs +++ /dev/null @@ -1,162 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices.JavaScript; -using System.Threading; -using System.Threading.Tasks; -using System.Diagnostics.Tracing; - - -namespace Sample -{ - - [EventSource(Name = "WasmHello")] - public class WasmHelloEventSource : EventSource - { - public static readonly WasmHelloEventSource Instance = new (); - - private IncrementingEventCounter _calls; - - private WasmHelloEventSource () - { - } - - [NonEvent] - public void NewCallsCounter() - { - _calls?.Dispose(); - _calls = new ("fib-calls", this) - { - DisplayName = "Recursive Fib calls", - }; - } - - [NonEvent] - public void CountCall() { - _calls?.Increment(1.0); - } - - protected override void Dispose (bool disposing) - { - _calls?.Dispose(); - _calls = null; - - base.Dispose(disposing); - } - - [Event(1, Message="Started Fib({0})", Level = EventLevel.Informational)] - public void StartFib(int n) - { - if (!IsEnabled()) - return; - - WriteEvent(1, n); - } - - [Event(2, Message="Stopped Fib({0}) = {1}", Level = EventLevel.Informational)] - public void StopFib(int n, string result) - { - if (!IsEnabled()) - return; - - WriteEvent(2, n, result); - } - } - - public partial class Test - { - public static void Main(string[] args) - { - // not called. See main.js for all the interesting bits - } - - private static int iterations; - private static CancellationTokenSource cts; - - public static CancellationToken GetCancellationToken() - { - cts ??= new CancellationTokenSource (); - return cts.Token; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static long recursiveFib (int n) - { - if (n < 1) - return 0; - if (n == 1) - return 1; - WasmHelloEventSource.Instance.CountCall(); - return recursiveFib (n - 1) + recursiveFib (n - 2); - } - -#if false - // dead code to prove that starting user threads isn't possible on the perftracing runtime - public static void Meth() { - Thread.Sleep (500); - while (!GetCancellationToken().IsCancellationRequested) { - Console.WriteLine ("ping"); - Thread.Sleep (500); - } - } -#endif - - [JSExport] - public static async Task StartAsyncWork(int N) - { - CancellationToken ct = GetCancellationToken(); -#if false - new Thread(new ThreadStart(Meth)).Start(); -#endif - await Task.Delay(1); - long b; - WasmHelloEventSource.Instance.NewCallsCounter(); - iterations = 0; - while (true) - { - WasmHelloEventSource.Instance.StartFib(N); - await Task.Delay(1); - b = recursiveFib (N); - WasmHelloEventSource.Instance.StopFib(N, b.ToString()); - iterations++; - if (ct.IsCancellationRequested) - break; - } - long expected = fastFib(N); - if (expected == b) - return (double)b; - else { - Console.Error.WriteLine ("expected {0}, but got {1}", expected, b); - return 0.0; - } - } - - [JSExport] - public static void StopWork() - { - cts.Cancel(); - } - - [JSExport] - public static string GetIterationsDone() - { - return iterations.ToString(); - } - - private static long fastFib(int N) { - if (N < 1) - return 0; - long a = 0; - long b = 1; - for (int i = 1; i < N; ++i) { - long tmp = a+b; - a = b; - b = tmp; - } - return b; - } - - } -} 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 deleted file mode 100644 index bf56a93391a17..0000000000000 --- a/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - true - true - true - - $(NoWarn);CA2007 - - - - true - - - - - - - - - - - - - - true - - - - - - - - - - - diff --git a/src/mono/sample/wasm/browser-eventpipe/index.html b/src/mono/sample/wasm/browser-eventpipe/index.html deleted file mode 100644 index f5847995e468f..0000000000000 --- a/src/mono/sample/wasm/browser-eventpipe/index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Sample EventPipe profile session - - - - - - - -
- - -
-
Computing Fib(N) repeatedly: - - - diff --git a/src/mono/sample/wasm/browser-eventpipe/main.js b/src/mono/sample/wasm/browser-eventpipe/main.js deleted file mode 100644 index 2bf5dc8d9ff9a..0000000000000 --- a/src/mono/sample/wasm/browser-eventpipe/main.js +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -import { dotnet, exit } from "./dotnet.js"; - -const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) - -async function doWork(startWork, stopWork, getIterationsDone) { - const N = parseInt(document.getElementById("inputN").value); - - - const workPromise = startWork(N); - - let btn = document.getElementById("startWork"); - btn.disabled = true; - btn.innerText = "Working"; - document.getElementById("out").innerHTML = '...'; - - await delay(5000); // let it run for 5 seconds - - document.getElementById("startWork").innerText = "Stopping"; - document.getElementById("out").innerHTML = '... ...'; - - stopWork(); - - const ret = await workPromise; // get the answer - const iterations = getIterationsDone(); // get how many times the loop ran - - INTERNAL.diagnosticServerThread.postMessageToWorker({ - type: "diagnostic_server_mock", - cmd: "fibonacci-done" - }); - - btn = document.getElementById("startWork"); - btn.disabled = false; - btn.innerText = "Start Work"; - - document.getElementById("out").innerHTML = `${ret} as computed in ${iterations} iterations`; - - console.debug(`ret: ${ret}`); - - return ret; -} - -const isTest = (config) => config.environmentVariables["CI_TEST"] === "true"; -async function runTest({ StartAsyncWork, StopWork, GetIterationsDone }) { - const result = await doWork(StartAsyncWork, StopWork, GetIterationsDone); - const expectedResult = 55; // the default value of `inputN` is 10 (see index.html) - return result === expectedResult; -} - -async function main() { - const { INTERNAL, MONO, Module, getAssemblyExports, getConfig } = await dotnet - .withElementOnExit() - .withExitCodeLogging() - .withDiagnosticTracing(false) - .create(); - - globalThis.__Module = Module; - globalThis.MONO = MONO; - globalThis.INTERNAL = INTERNAL; - - const exports = await getAssemblyExports("Wasm.Browser.EventPipe.Sample.dll"); - - const btn = document.getElementById("startWork"); - btn.style.backgroundColor = "rgb(192,255,192)"; - btn.onclick = () => doWork(exports.Sample.Test.StartAsyncWork, exports.Sample.Test.StopWork, exports.Sample.Test.GetIterationsDone); - - INTERNAL.diagnosticServerThread.port.addEventListener("message", (event) => { - console.warn("diagnosticServerThread" + event.type) - - if (event.data.cmd === "collecting") { - btn.onclick(); - } - - if (event.data.cmd === "collected") { - const buffer = event.data.buffer; - const length = event.data.length; - console.warn("Downloading trace " + length) - const view = new Uint8Array(buffer, 0, length) - const blobUrl = URL.createObjectURL(new Blob([view.slice()])); - const link = document.createElement("a"); - link.href = blobUrl; - link.download = "trace." + (new Date()).valueOf() + ".nettrace"; - document.body.appendChild(link); - - link.dispatchEvent(new MouseEvent('click', { - bubbles: true, cancelable: true, view: window - })); - - document.body.removeChild(link); - } - }); - - const config = getConfig(); - if (isTest(config)) { - const succeeded = await runTest(exports.Sample.Test); - exit(succeeded ? 0 : 1); - } -} - -main(); 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/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/test-main.js b/src/mono/wasm/test-main.js index 1c82380edaf9c..319e5618d344d 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -136,6 +136,8 @@ function processArguments(incomingArguments, runArgs) { runArgs.forwardConsole = false; } else if (currentArg == "--no-memory-snapshot") { runArgs.memorySnapshot = false; + } else if (currentArg == "--use-threads") { + runArgs.environmentVariables["IsBrowserThreadingSupported"] = "true"; } else if (currentArg.startsWith("--fetch-random-delay=")) { const arg = currentArg.substring("--fetch-random-delay=".length); if (is_browser) { diff --git a/src/mono/wasm/threads.md b/src/mono/wasm/threads.md index bf75f46137b6a..3db89b94d8985 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[] From 23868123563c3ae7cabefccab8151d6f5c9b15d9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 19 Jun 2023 21:35:19 +0200 Subject: [PATCH 2/4] whitespace --- src/mono/wasm/threads.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/threads.md b/src/mono/wasm/threads.md index 3db89b94d8985..d5fc9e5e63f4a 100644 --- a/src/mono/wasm/threads.md +++ b/src/mono/wasm/threads.md @@ -6,7 +6,7 @@ Build the runtime with `/p:MonoWasmBuildVariant=multithread` to enable support f ## Building sample apps ## -Sample apps use the "public" properties `WasmEnableThreads` to enable the relevant functionality. +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 ## From c15ea1f5652b265f7fe89d960c03712663707e8b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 19 Jun 2023 23:39:25 +0200 Subject: [PATCH 3/4] feedback + fixes --- .../runtime-extra-platforms-wasm.yml | 6 +- src/libraries/tests.proj | 1 + src/mono/sample/wasm/Directory.Build.props | 1 - src/mono/sample/wasm/Directory.Build.targets | 5 +- .../sample/wasm/browser-eventpipe/Makefile | 13 ++ .../sample/wasm/browser-eventpipe/Program.cs | 165 ++++++++++++++++++ .../sample/wasm/browser-eventpipe/README.md | 4 +- .../Wasm.Browser.EventPipe.Sample.csproj | 49 ++++++ .../sample/wasm/browser-eventpipe/index.html | 22 +++ .../sample/wasm/browser-eventpipe/main.js | 107 ++++++++++++ .../sample/wasm/browser-threads/Program.cs | 2 +- src/mono/wasm/runtime/diagnostics/index.ts | 3 +- src/mono/wasm/runtime/startup.ts | 23 +-- 13 files changed, 380 insertions(+), 21 deletions(-) create mode 100644 src/mono/sample/wasm/browser-eventpipe/Makefile create mode 100644 src/mono/sample/wasm/browser-eventpipe/Program.cs create mode 100644 src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj create mode 100644 src/mono/sample/wasm/browser-eventpipe/index.html create mode 100644 src/mono/sample/wasm/browser-eventpipe/main.js diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml index 625e6c0e130c7..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 @@ -244,7 +244,7 @@ jobs: platforms: - Browser_wasm - Browser_wasm_win - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) nameSuffix: DebuggerTests_MultiThreaded alwaysRun: ${{ parameters.isWasmOnlyBuild }} isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }} diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 129556b394af8..0db1894960572 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -52,6 +52,7 @@ + diff --git a/src/mono/sample/wasm/Directory.Build.props b/src/mono/sample/wasm/Directory.Build.props index 57a456b3720e4..86e58535e0071 100644 --- a/src/mono/sample/wasm/Directory.Build.props +++ b/src/mono/sample/wasm/Directory.Build.props @@ -6,7 +6,6 @@ browser wasm browser-wasm - multithread $(NoWarn);IL2121 diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets index 4238580d7fb55..10b8211e3c554 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -9,9 +9,8 @@ $([MSBuild]::NormalizePath('$(WasmAppDir)', '$(RunScriptOutputName)')) - <_MonoWasmThreads Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">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 + $(WasmXHarnessArgs) --web-server-use-cop + <_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/Makefile b/src/mono/sample/wasm/browser-eventpipe/Makefile new file mode 100644 index 0000000000000..b029e47ddbd15 --- /dev/null +++ b/src/mono/sample/wasm/browser-eventpipe/Makefile @@ -0,0 +1,13 @@ +TOP=../../../../.. + +include ../wasm.mk + +override MSBUILD_ARGS+=/p:WasmEnablePerfTracing=true + +ifneq ($(AOT),) +override MSBUILD_ARGS+=/p:RunAOTCompilation=true +endif + +PROJECT_NAME=Wasm.Browser.EventPipe.Sample.csproj + +run: run-browser diff --git a/src/mono/sample/wasm/browser-eventpipe/Program.cs b/src/mono/sample/wasm/browser-eventpipe/Program.cs new file mode 100644 index 0000000000000..e04922cf95558 --- /dev/null +++ b/src/mono/sample/wasm/browser-eventpipe/Program.cs @@ -0,0 +1,165 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices.JavaScript; +using System.Threading; +using System.Threading.Tasks; +using System.Diagnostics.Tracing; + + +namespace Sample +{ + + [EventSource(Name = "WasmHello")] + public class WasmHelloEventSource : EventSource + { + public static readonly WasmHelloEventSource Instance = new (); + + private IncrementingEventCounter _calls; + + private WasmHelloEventSource () + { + } + + [NonEvent] + public void NewCallsCounter() + { + _calls?.Dispose(); + _calls = new ("fib-calls", this) + { + DisplayName = "Recursive Fib calls", + }; + } + + [NonEvent] + public void CountCall() { + _calls?.Increment(1.0); + } + + protected override void Dispose (bool disposing) + { + _calls?.Dispose(); + _calls = null; + + base.Dispose(disposing); + } + + [Event(1, Message="Started Fib({0})", Level = EventLevel.Informational)] + public void StartFib(int n) + { + if (!IsEnabled()) + return; + + WriteEvent(1, n); + } + + [Event(2, Message="Stopped Fib({0}) = {1}", Level = EventLevel.Informational)] + public void StopFib(int n, string result) + { + if (!IsEnabled()) + return; + + WriteEvent(2, n, result); + } + } + + public partial class Test + { + public static void Main(string[] args) + { + // not called. See main.js for all the interesting bits + } + + private static int iterations; + private static CancellationTokenSource cts; + + public static CancellationToken GetCancellationToken() + { + cts ??= new CancellationTokenSource (); + return cts.Token; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static long recursiveFib (int n) + { + if (n < 1) + return 0; + if (n == 1) + return 1; + WasmHelloEventSource.Instance.CountCall(); + return recursiveFib (n - 1) + recursiveFib (n - 2); + } + +#if false + // dead code to prove that starting user threads isn't possible on the perftracing runtime + public static void Meth() { + Thread.Sleep (500); + while (!GetCancellationToken().IsCancellationRequested) { + Console.WriteLine ("ping"); + Thread.Sleep (500); + } + } +#endif + + [JSExport] + public static async Task StartAsyncWork(int N) + { + CancellationToken ct = GetCancellationToken(); +#if false + new Thread(new ThreadStart(Meth)).Start(); +#endif + await Task.Delay(1); + long b; + WasmHelloEventSource.Instance.NewCallsCounter(); + iterations = 0; + while (true) + { + WasmHelloEventSource.Instance.StartFib(N); + await Task.Delay(1); + 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 { + Console.Error.WriteLine ("expected {0}, but got {1}", expected, b); + return 0.0; + } + } + + [JSExport] + public static void StopWork() + { + cts.Cancel(); + } + + [JSExport] + public static string GetIterationsDone() + { + return iterations.ToString(); + } + + private static long fastFib(int N) { + if (N < 1) + return 0; + long a = 0; + long b = 1; + for (int i = 1; i < N; ++i) { + long tmp = a+b; + a = b; + b = tmp; + } + return b; + } + + } +} diff --git a/src/mono/sample/wasm/browser-eventpipe/README.md b/src/mono/sample/wasm/browser-eventpipe/README.md index 41e10bc7b8bbb..3e17a6c32cabe 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:FeatureWasmThreads=true` 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. 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 new file mode 100644 index 0000000000000..f2d30b6399497 --- /dev/null +++ b/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj @@ -0,0 +1,49 @@ + + + + true + true + true + true + $(NoWarn);CA2007 + + + + true + + + + + + + + + + + + + + true + + + + + + + + + + + diff --git a/src/mono/sample/wasm/browser-eventpipe/index.html b/src/mono/sample/wasm/browser-eventpipe/index.html new file mode 100644 index 0000000000000..f5847995e468f --- /dev/null +++ b/src/mono/sample/wasm/browser-eventpipe/index.html @@ -0,0 +1,22 @@ + + + + + + + Sample EventPipe profile session + + + + + + + +
+ + +
+
Computing Fib(N) repeatedly: + + + diff --git a/src/mono/sample/wasm/browser-eventpipe/main.js b/src/mono/sample/wasm/browser-eventpipe/main.js new file mode 100644 index 0000000000000..683c076b579dd --- /dev/null +++ b/src/mono/sample/wasm/browser-eventpipe/main.js @@ -0,0 +1,107 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { dotnet, exit } from "./dotnet.js"; + +const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) + +async function doWork(startWork, stopWork, getIterationsDone) { + const N = parseInt(document.getElementById("inputN").value); + + + const workPromise = startWork(N); + + let btn = document.getElementById("startWork"); + btn.disabled = true; + btn.innerText = "Working"; + document.getElementById("out").innerHTML = '...'; + + await delay(5000); // let it run for 5 seconds + + document.getElementById("startWork").innerText = "Stopping"; + document.getElementById("out").innerHTML = '... ...'; + + stopWork(); + + const ret = await workPromise; // get the answer + const iterations = getIterationsDone(); // get how many times the loop ran + + INTERNAL.diagnosticServerThread.postMessageToWorker({ + type: "diagnostic_server_mock", + cmd: "fibonacci-done" + }); + + btn = document.getElementById("startWork"); + btn.disabled = false; + btn.innerText = "Start Work"; + + document.getElementById("out").innerHTML = `${ret} as computed in ${iterations} iterations`; + + console.debug(`ret: ${ret}`); + + return ret; +} + +const isTest = (config) => config.environmentVariables["CI_TEST"] === "true"; +async function runTest({ StartAsyncWork, StopWork, GetIterationsDone }) { + const result = await doWork(StartAsyncWork, StopWork, GetIterationsDone); + const expectedResult = 55; // the default value of `inputN` is 10 (see index.html) + return result === expectedResult; +} + +async function main() { + const { INTERNAL, MONO, Module, getAssemblyExports, getConfig } = await dotnet + .withElementOnExit() + .withExitCodeLogging() + .withDiagnosticTracing(false) + .create(); + + globalThis.__Module = Module; + globalThis.MONO = MONO; + globalThis.INTERNAL = INTERNAL; + + const exports = await getAssemblyExports("Wasm.Browser.EventPipe.Sample.dll"); + + const btn = document.getElementById("startWork"); + 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) + + if (event.data.cmd === "collecting") { + btn.onclick(); + } + + if (event.data.cmd === "collected") { + const buffer = event.data.buffer; + const length = event.data.length; + console.warn("Downloading trace " + length) + const view = new Uint8Array(buffer, 0, length) + const blobUrl = URL.createObjectURL(new Blob([view.slice()])); + const link = document.createElement("a"); + link.href = blobUrl; + link.download = "trace." + (new Date()).valueOf() + ".nettrace"; + document.body.appendChild(link); + + link.dispatchEvent(new MouseEvent('click', { + bubbles: true, cancelable: true, view: window + })); + + document.body.removeChild(link); + } + }); + + const config = getConfig(); + if (isTest(config)) { + const succeeded = await runTest(exports.Sample.Test); + exit(succeeded ? 0 : 1); + } +} + +main(); 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/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) From 3c671b5c472d53e2b2c37fb6b7f1b7908bd98661 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 20 Jun 2023 11:25:57 +0200 Subject: [PATCH 4/4] feedback + fix --- eng/testing/tests.browser.targets | 2 +- .../ref/System.Threading.Thread.csproj | 1 + .../WorkloadManifest.targets.in | 7 +++++++ src/mono/sample/wasm/DefaultBrowserSample.targets | 1 + src/mono/sample/wasm/Directory.Build.props | 1 - src/mono/sample/wasm/Directory.Build.targets | 1 - src/mono/sample/wasm/browser-eventpipe/README.md | 4 ++-- .../browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj | 5 +---- .../Wasm.Browser.Threads.Minimal.Sample.csproj | 2 +- .../browser-threads/Wasm.Browser.Threads.Sample.csproj | 2 +- src/mono/wasm/test-main.js | 2 -- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index 71968c3030aae..e48831cc61d6a 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -99,7 +99,7 @@ $(WasmXHarnessMonoArgs) --no-memory-snapshot - $(WasmXHarnessMonoArgs) --use-threads + $(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true 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/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 e1de687de9e50..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 @@ -175,4 +175,11 @@ + + + + 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 86e58535e0071..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 10b8211e3c554..b61806bd837df 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -9,7 +9,6 @@ $([MSBuild]::NormalizePath('$(WasmAppDir)', '$(RunScriptOutputName)')) - $(WasmXHarnessArgs) --web-server-use-cop <_ServeHeaders Condition="'$(WasmEnableThreads)' == 'true'">$(_ServeHeaders) -h Cross-Origin-Embedder-Policy:require-corp -h Cross-Origin-Opener-Policy:same-origin diff --git a/src/mono/sample/wasm/browser-eventpipe/README.md b/src/mono/sample/wasm/browser-eventpipe/README.md index 3e17a6c32cabe..bbbf5d872a834 100644 --- a/src/mono/sample/wasm/browser-eventpipe/README.md +++ b/src/mono/sample/wasm/browser-eventpipe/README.md @@ -1,6 +1,6 @@ [see also](../../../wasm/runtime/diagnostics/README.md) -To be able to run this sample you need to build the runtime with `/p:FeatureWasmThreads=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 @@ -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 f2d30b6399497..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-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/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/wasm/test-main.js b/src/mono/wasm/test-main.js index 319e5618d344d..1c82380edaf9c 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -136,8 +136,6 @@ function processArguments(incomingArguments, runArgs) { runArgs.forwardConsole = false; } else if (currentArg == "--no-memory-snapshot") { runArgs.memorySnapshot = false; - } else if (currentArg == "--use-threads") { - runArgs.environmentVariables["IsBrowserThreadingSupported"] = "true"; } else if (currentArg.startsWith("--fetch-random-delay=")) { const arg = currentArg.substring("--fetch-random-delay=".length); if (is_browser) {