Blazor - Is Emcripten NuGet package intentionally missing the multithreaded libs?

Johnathan Waring 21 Reputation points


I was wondering if it is intentional that the NuGet package of Emscripten is missing the '-mt.a libs' from 'emscripten\cache\sysroot\lib\wasm32-emscripten'. I checked out the github copy emscripten and followed the steps to set it up and it's has all of the *-mt.a libs present.

Below is a sceenshot with the NuGet libs (left) and the github libs (right):

I could be missing something in the setup of my Blazor project, but it may also be a feature not supported yet. Judging by the file size differences, emscritpen is built differently for the NuGet package.

Below is what I followed to setup my Blazor client project:

I wanted to try out running C/C++ code in Blazor, which is amazing. I decided to try threaded C++ code following this post:

I added the following to the Blazor Client csproj to use the C++ threads (assuming I've got this right):

When building it produces the following error:
Exception: FROZEN_CACHE is set, but cache file is missing: "sysroot\lib\wasm32-emscripten\libgl-mt.a" (in cache root path "C:\Program Files\dotnet\packs\\6.0.0\tools\emscripten\cache")

Appreciate any information on this.

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
795 questions
No comments
{count} votes

Accepted answer
  1. Bruce ( 28,276 Reputation points

    Web assembly does not support threads. Though messaging to JavaScript is async, so you can use JavaScript to implement async operations.

    Note: while the blazor WASM supports the thread library, they are all just calls on the same thread, so unless they are calling JavaScript they are sync.

    No comments

2 additional answers

Sort by: Most helpful
  1. Johnathan Waring 21 Reputation points

    Thanks for fast reply Bruce. I had a feeling I was mis-leading myself.


    No comments

  2. Bruce Barker 796 Reputation points

    currently the browser has pretty limited thread support

    one thread for javascript (UI thread)
    one thread per web assembly sandbox
    one thread per service worker (javascript only)
    one thread per web worker (javascript only)

    there is a messaging library for threads to talk to each other. there is no shared memory as there is no locking.

    note: just as web assembly has a project to support GC's, there is one for thread support.