unoplatform / Uno.Wasm.Bootstrap

A simple nuget package to run C# code in a WASM-compatible browser
Other
367 stars 57 forks source link

[WASM] Multithreading with .Net8 doesn't work because Uno.WASM.MetadataUpdate is compiled with .net7? #780

Closed Rippletank closed 11 months ago

Rippletank commented 11 months ago

UnoWASMnet80Threading.zip

Current behavior

A simple .net8.0, WASM only solution created using the latest template (according to uno-check) with all of the uno and Microsoft packages updated to latest dev/rc releases.

With no multithreading, the app starts ok.

With threading enabled using <WasmShellEnableThreads>true</WasmShellEnableThreads> startup aborts at line 359 of uno-bootstrap.js await this.setupHotReload()

The error appears to be at line 63: let exports = await getAssemblyExports("Uno.Wasm.MetadataUpdater"); with error, "Could not load content for file:///D:/a/Uno.DotnetRuntime.WebAssembly/Uno.DotnetRuntime.WebAssembly/runtime/src/mono/wasm/runtime/invoke-cs.ts (System error: net::ERR_FILE_NOT_FOUND)"

Expected behavior

Expected behaviour is for the threaded version to load fully as with the unthreaded version.

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

    <PackageReference Include="Uno.Resizetizer" Version="1.2.0-dev.68" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.0-rc.1.23420.5" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="8.0.0-dev.291" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="8.0.0-dev.291" />
    <PackageReference Include="Uno.WinUI.WebAssembly" Version="5.0.0-dev.3369" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="5.0.0-dev.3369" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.0.0-dev.3369" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.7.0-dev.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.1.23419.4" />

Affected platforms

WebAssembly

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Rippletank commented 11 months ago

Ok, after looking again with fresh eyes and getting hold of the typescript files, I have found the error.

"JSExport with multi-threading enabled is not supported with assembly ${assembly} as it was generated with the .NET 7 SDK" for assembly = Uno.WASM.MetadataUpdate

As I am digging into the unknown (for me), I'm putting this here as it seems like it might make sense to someone more knowledgeable. Meanwhile, I can't immediately see where this assembly is coming from so I will keep digging.

Rippletank commented 11 months ago

Workaround: Unsuccessfully, tried to find a way to disable hot-reload before the app is loaded in debug mode, but Release mode works properly without an error.

jeromelaban commented 11 months ago

Thanks for the report.

We'll likely need to build this project with net8 instead.

Rippletank commented 11 months ago

Thanks, can confirm the using latest builds (dev.3455) app now runs fully in debug mode with threading.

However, just for information, when multithreading is enabled, breakpoints are not hit and the browser window is disconnected from the server. The only difference in terms of console messages is the following error in multithreaded mode:

Unable to set option 'no-jiterpreter-traces-enabled' as it's read-only. dotnet.native.js

I'm guessing that's a dotnet issue, though. Work arounds are just console debugging or switching off multithreading temporarily, but at least with shorter compile times of debug mode.