-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasm-mt] Issues with enabling threads in .NET 7 RC 1 #74654
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsUsing the Issues:
Detailed reproduction steps
$ dotnet build
MSBuild version 17.4.0-preview-22416-02+5d102ae37 for .NET
Determining projects to restore...
Restored /Users/alklig/work/net7-playground/hithread/browser.csproj (in 2 ms).
/Users/alklig/work/net7-nightly/sdk/7.0.100-rc.2.22425.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/Users/alklig/work/net7-playground/hithread/browser.csproj]
browser -> /Users/alklig/work/net7-playground/hithread/bin/Debug/net7.0/browser-wasm/browser.dll
Compiling native assets with emcc with -O0. This may take a while ...
[2/3] corebindings.c -> corebindings.o [took 0.384s]
[1/3] pinvoke.c -> pinvoke.o [took 0.384s]
[3/3] driver.c -> driver.o [took 0.416s]
Linking for initial memory $(EmccInitialHeapSize)=536870912 bytes. Set this msbuild property to change the value.
Linking with emcc with -O0. This may take a while ...
...
Exception: FROZEN_CACHE is set, but cache file is missing: "sysroot/lib/wasm32-emscripten/libGL-mt.a" (in cache root path "/Users/alklig/work/net7-nightly/packs/Microsoft.NET.Runtime.Emscripten.3.1.12.Sdk.osx-x64/8.0.0-alpha.1.22415.5/tools/emscripten/cache")
/Users/alklig/work/net7-nightly/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/7.0.0-rc.1.22422.12/Sdk/WasmApp.Native.targets(422,5): error MSB3073: The command "emcc "@/Users/alklig/work/net7-nightly/packs/Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm/7.0.0-rc.1.22422.12/runtimes/browser-wasm/native/src/emcc-default.rsp" "@/Users/alklig/work/net7-nightly/packs/Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm/7.0.0-rc.1.22422.12/runtimes/browser-wasm/native/src/emcc-link.rsp" "@/Users/alklig/work/net7-playground/hithread/obj/Debug/net7.0/browser-wasm/wasm/for-build/emcc-link.rsp"" exited with code 1. [/Users/alklig/work/net7-playground/hithread/browser.csproj] Bug 4 We removed the cp ~/work/dotnet-runtime/runtime/src/mono/wasm/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/*-mt.a ~/work/net7-nightly/packs/Microsoft.NET.Runtime.Emscripten.3.1.12.Sdk.osx-x64/8.0.0-alpha.1.22415.5/tools/emscripten/cache/sysroot/lib/wasm32-emscripten
MONO_WASM: worker initializing essential C exports and APIs
MONO_WASM: worker initializing essential C exports and APIs
MONO_WASM: worker initializing essential C exports and APIs
MONO_WASM: worker initializing essential C exports and APIs
dotnet.js:5 MONO_WASM: afterLoadWasmModuleToWorker added message event handler Worker {onmessage: ƒ, onerror: ƒ}
dotnet.js:5 MONO_WASM: afterLoadWasmModuleToWorker added message event handler Worker {onmessage: ƒ, onerror: ƒ}
dotnet.js:5 MONO_WASM: afterLoadWasmModuleToWorker added message event handler Worker {onmessage: ƒ, onerror: ƒ}
dotnet.js:5 MONO_WASM: afterLoadWasmModuleToWorker added message event handler Worker {onmessage: ƒ, onerror: ƒ}
dotnet.js:5 MONO_WASM: worker initializing essential C exports and APIs
dotnet.js:5 MONO_WASM: worker initializing essential C exports and APIs
dotnet.js:5 MONO_WASM: worker initializing essential C exports and APIs
dotnet.js:5 MONO_WASM: worker initializing essential C exports and APIs
dotnet.js:3 mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
dotnet.js:2013 Hello, Console!
<PropertyGroup>
<WasmEnableThreads>true</WasmEnableThreads>
<WasmEnableThreading>true</WasmEnableThreading>
<WasmGenerateAppBundle>true</WasmGenerateAppBundle>
</PropertyGroup> That is, replace
|
@radekdoulik @lewing I guess our biggest problem is going to be
because that runs up against the nuget size limit? |
I can take care of the rest. |
A bit more detail on teh last point: it seems like |
Maybe for net7 RC2 we can focus on for net7 RTM we probably should have the |
Ah there's one more issue: public class MyClass {
[MethodImpl(MethodImplOptions.NoInlining)]
public static string CallMeFromJS()
{
new Thread(Loop).Start();
return "Hello, World!";
}
public static void Loop() {
for (int i = 0; i < 5; ++i) {
Console.WriteLine ("Thread ping!");
Thread.Sleep (100);
}
}
} results in Which means we didn't build CoreLib for threading. Probably needs to check for |
I'm not sure how to fix
As far as I can tell the file is in the template directory https://github.com/dotnet/runtime/tree/main/src/mono/wasm/templates/templates/browser Note also that |
@sayedihashimi Do you know why |
@lambdageek do you have a nuget package that I can try out? Or is there some specific steps that I should follow to try it out? |
@lambdageek I cloned the repo and ran |
Thanks @sayedihashimi, I'll try your simplified repro steps. It's entirely possible that it's some old cache on my machine. (Our existing repro steps involve a local .net sdk install followed by workload installation from artifacts/, so it may be that my local install has some older bits in it) |
@lambdageek after you give it a try, let me know if you have any more questions. |
I'm all set. it works on another machine. I think I had an older build |
Looks like we will probably get AOT in RC2, also 🎉 |
are we done here? |
We're done. Using an RC2 installer from https://github.com/dotnet/installer, we now have RC2 runtime packs where
|
Using the
wasm-experimental
workload it shoudl be possible to create multi-threadedwasmbrowser
projects in .NET 7 RC1Issues:
main
by [wasm-mt] Fix pack/build issues in threaded builds #75162 and onrelease/7.0
by [release/7.0][wasm-mt] Fix pack/build issues in threaded builds #75171WasmGenerateAppBundle
doesn't create multi-threaded builds withWasmEnableThreads
- onlyWasmBuildNative
does - due todotnet.worker.js
missing from the runtime packWorkloadManifest.targets.in
usesWasmEnableThreading
instead ofWasmEnableThreads
multithread
andperftrace
build variants don't define the correct feature flags.dotnet new wasmbrowser
createsbrowser.csproj
, not<dirname>.csproj
this looks like a local caching issuedotnet new wasmbrowser
does not createruntimeconfig.template.json
required fordotnet run
Detailed reproduction steps
${HOME}/work/net7-nightly
DOTNET_ROOT
andPATH
:${HOME}/work/net7-playground
and add the following into${HOME}/work/net7-playground/NuGet.config
net7-playground
directory (so thatNuGet.config
is in the current dir), install thewasm-experimental
workload:${HOME}/work/net7-playground/hithread
and create awasmbrowser
project:browser.csproj
nothithread.csproj
- other templates create a .csproj file with the same name as the directory.runtimeconfig.template.json
with teh following contentbrowser.csproj
WorkloadManifest.targets.in
has a typo and usesWasmEnableThreading
instead ofWasmEnableThreads
dotnet build
Bug 4 We removed the
*-mt.a
static libraries in our EMSDK pack9. Copy
*-mt.a
from an upstream EMSDK install into the emsdk pack:cp ~/work/dotnet-runtime/runtime/src/mono/wasm/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/*-mt.a ~/work/net7-nightly/packs/Microsoft.NET.Runtime.Emscripten.3.1.12.Sdk.osx-x64/8.0.0-alpha.1.22415.5/tools/emscripten/cache/sysroot/lib/wasm32-emscripten
dotnet build
should now succeed.dotnet run
shoudl serve the app. Open the URL in Chrome and open dev tools and hit reload. You should see something like this in the console:bin
andobj
directories.Change the
browser.csproj
like this:That is, replace
WasmBuildNative
byWasmGenerateAppBundle
12. run
dotnet build
again. Note thatdotnet.worker.js
isn't in the AppBundle directory. When runningthe app prints 404s when trying to load it. From the Chrome DevTools console:
The text was updated successfully, but these errors were encountered: