Open
Description
Godot version
v4.0.beta10.mono.official [d0398f6]
System information
macOS Monterey 12.5.1 (21G83)
Issue description
In a fresh project created with v4.0beta10 and export templates downloaded and installed, the web export templates files are missing at the expected path. This makes it impossible to create web builds afaik.
Steps to reproduce
- Create new godot project with v4.0beta10
- Create web export preset
- Download export templates
- Click on open folder in the export template download window
- Observe that the required files for web exports are missing
Minimal reproduction project
N/A
Activity
Calinou commentedon Jan 2, 2023
There are no C# export templates for HTML5 yet due to missing upstream support in .NET 6 (.NET 7 didn't address this).
That said, there are significant issues with the HTML5 export in 4.0, such as #68647 and #70691. I would recommend using 3.x if targeting HTML5 for now, regardless of whether you're using C# or not.
Delpire commentedon Jan 16, 2023
What is the missing upstream support from .NET we're waiting on to get HTML5 support? Can we link that item here and then in whatever documentation gets created?
Not having HTML5 support for Godot 4 is preventing me from using Godot 4 when participating in game jams as I prefer uploading web builds.
66 remaining items
raulsntos commentedon Dec 16, 2024
Side modules is for dynamic linking, they may be statically linking dependencies. But that also has some requirements, the WASM you're linking needs to be relocatable.
No, just build a Godot project with NativeAOT-LLVM. See instructions in their documentation.
Here's an example
.csproj:Then use this command to build:
Delsin-Yu commentedon Dec 16, 2024
I guess this implies that the Godot Wasm can't be relocatable and hence cannot be statically linked to the Dotnet user Wasm?
jolexxa commentedon Dec 23, 2024
@raulsntos I'm curious if it's valid solution (or why not) to leverage Godot as a library just for C# web exports and have a C# managed entry point. I imagine that'd need a bit of effort on the export side of things in Godot, but then at least the effort would be constrained to Godot itself and not dependent on .NET (which is clearly moving at its own pace).
Unrelated, but the bounty is now at ~$1,600 😄
lucasabbas commentedon Jan 10, 2025
If the Godot and .NET can't be linked together, why not try running .NET code using a WASM interperter like WASM-3
danroth27 commentedon Jan 11, 2025
@raulsntos I'd be interested in discussing what godot need on the .NET side to unblock this scenario so that we at least understand what the work is involved here. It sounds like you're blocked on dotnet/runtime#75257, correct? Is there anything else?
raulsntos commentedon Jan 12, 2025
Hello @danroth27 👋, thanks for reaching out.
Yes, dotnet/runtime#75257 seems to be the main blocker. We intend to load the .NET WASM dynamically from the main Godot WASM. To give more context, the main Godot WASM is pre-built and distributed to users so they don't have to build the engine themselves.
We also tried the experimental NativeAOT-LLVM which allows us to specify additional emscripten flags with
<LinkerArg Include="-sSIDE_MODULE=2"/>, but run intowasm-lderrors (likely because some of the .NET libraries are built with incompatible flags).As I understand it, Microsoft had a lot of problems with emscripten's dynamic linking in the past, so I assume it's unsupported but I'm not aware of the specific issues you ran into.
We also tried linking Mono statically and in this case we run into issues with retrieving function pointers. It seems .NET is supposed to build a table of function pointers out of methods annotated with
[UnmanagedCallersOnly]but I haven't been able to trigger that, maybe there's an undocumented MSBuild property that I'm not aware of. We'd still prefer the dynamic linking options mentioned above, but I thought I'd also mention this because it could unblock us in the short term.There's more details about what we've tried in my previous comment: #70796 (comment)
danroth27 commentedon Jan 12, 2025
@lewing Any ideas on what might be happening here?
@raulsntos Can you share with us more specifics on these issues you hit with static linking, like the related code and the specific errors?
raulsntos commentedon Jan 12, 2025
Sure, here are the details of what I've done:
I'm building the main Godot WASM including the sources from Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm/9.0.0 (I've also used 8.0.0 in the past and I had the same results).
Then, on C++ I use
mono_wasm_load_runtime,mono_assembly_load, andmono_runtime_invoketo initialize the .NET runtime, load the assembly, and call a function on the C# side to initialize some Godot stuff.For our initialization, we take the function pointer of some C# methods and pass them to the C++ side so we can invoke them from the native engine side. The problem is that these function pointers all seem to be
null. Here's an example of what I mean:No errors or exceptions, but since the value is
nullwe can't call the function, so we can't finish the engine initialization.Here's the command we use to publish the .NET project:
dotnet publish UserProject.csproj -c ExportDebug -r browser-wasm --self-contained true -p:GodotTargetPlatform=web -o /tmp/godot-publish-dotnet/192660-ExportDebug-browser-wasmNote that, since we have custom configurations, we also set the property
<WasmBuildNative>totruein our MSBuild SDK, which seems to match what theReleaseconfiguration does. We may have missed other properties, but this seems to be something we can workaround. See relevant issues: dotnet/runtime#104540 and dotnet/sdk#31918xuanyusong commentedon Jan 20, 2025
Unity Chinese version engine(团结引擎) converts Dll into WebCIL and interprets it through mono runtime. Can Godot use this method to run?
https://docs.unity.cn/cn/tuanjiemanual/Manual/WeixinMiniGameDotNetSupport.html
Delsin-Yu commentedon Jan 20, 2025
I believe the CN fork of Unity (aka Tuanjie) is only utilizing a small portion of the .Net 8 WASM toolkits for its
.Net 8backend, which requires many customized solutions. I doubt it can be used freely with future releases of .Net.xuanyusong commentedon Jan 21, 2025
unity(团结)Engine mentioned some implementation details. The il2cpp solution for generating WebAssembly will package the user code and the engine code together, and also deal with the generation of generic template code, which makes the Wasm file very large. Therefore, the il2cpp solution was abandoned and the Microsoft Blazor solution was adopted to separate the user C# code and Wasm runtime to interpret and execute C# code. The DotNet Wasm solution is based on .NET8, relies on the Emscripten tool chain to build WebAssembly, and uses the trimmed and optimized mono as the .Net runtime.
https://mp.weixin.qq.com/s/5xfq-EveRWmBnHMfC-icRA
Antoniojesus122 commentedon Feb 4, 2025
WithinAmnesia commentedon Feb 6, 2025
WithinAmnesia commentedon Feb 6, 2025