godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.21k stars 21.22k forks source link

Custom HTML5 export template of Godot Mono 3.4.4-stable fails to launch, complaining 'The assembly 'GodotSharp' is out of sync.' and 'unreachable' #60827

Open SysError99 opened 2 years ago

SysError99 commented 2 years ago

Godot version

3.4.4.stable.mono

System information

Linux 5.15.32-1-MANJARO (AMD Zen with Vega Mobile Graphics)

Issue description

I'm trying to build custom export template in version 3.4.4.stable which I will remove various of unused modules and enable optimize=speed option. The build process seems to go smoothly until I put it in custom template and export it on 3.4.4.stable editor and test run it. After loading process finishes, canvas only shows unreachable label, and debugging panel shows below (> represents each line of text)

> ERROR: The assembly 'GodotSharp' is out of sync.
>    at: _load_api_assemblies (modules/mono/mono_gd/gd_mono.cpp:954) - The assembly 'GodotSharp' is out of sync.
> ERROR: FATAL: Method failed.
>    at: _load_api_assemblies (modules/mono/mono_gd/gd_mono.cpp:965) - FATAL: Method failed.
> exception thrown: RuntimeError: unreachable,RuntimeError: unreachable
    at wasm://wasm/0412fade:wasm-function[63154]:0xcfcf3d
    at wasm://wasm/0412fade:wasm-function[63155]:0xcfcf69
    at wasm://wasm/0412fade:wasm-function[65413]:0xd54255
    at wasm://wasm/0412fade:wasm-function[32205]:0x5d8c1d
    at wasm://wasm/0412fade:wasm-function[29433]:0x52dc1e
    at wasm://wasm/0412fade:wasm-function[29469]:0x53285b
    at wasm://wasm/0412fade:wasm-function[14679]:0x2aaf29
    at wasm://wasm/0412fade:wasm-function[30750]:0x5930ee
    at Module._main (http://192.168.1.18:8080/GodotMonoHelloWorld/index.js:9:403460)
    at Object.callMain (http://192.168.1.18:8080/GodotMonoHelloWorld/index.js:9:415776)
> unreachable

image

This happen even if I have used bare-bone command to build the template and got approximately same size of template file compared to official build.

This is custom build one: image

And, this is official build: image

Ps: While building glue, there are some errors produced but it seems like the glue generator just ignored it. There are possibly more errors but my terminal got overflow and couldn't display all of them, but here's some example: Screenshot_20220506_212100

Steps to reproduce

Environment:

Steps: 1) Cloning project to local with git clone https://github.com/godotengine/godot . (I'm already in separated directory) 2) Switching branch to 3.4.4-stable with git checkout 3.4.4-stable 3) Start building Mono glue generator with:

scons p=x11 tools=yes module_mono_enabled=yes mono_glue=no -j 7

4) Start generating Mono glue with:

./bin/godot.x11.tools.64.mono --generate-mono-glue modules/mono/glue

5) Start building export template with command:

#!/bin/bash
source $HOME/EmscriptenSDK/emsdk_env.sh
cd $HOME/Godot.Source
emsdk activate 1.39.9
scons p=javascript --clean
scons profile=$HOME/Godot.Build.Profiles/JsMono.py -j 8 module_mono_enabled=yes mono_glue=yes mono_static=yes mono_prefix=$HOME/Godot.Mono.Releases/wasm-runtime-release

This is content of custom build file ($HOME/Godot.Mono.Releases/JsMono.py)

# Core
p="javascript"
tools="no"
target="release"
optimize="size"
use_lto="no"
disable_3d="no"
disable_advanced_gui="no"

6) Start building project with the build, in release mode. 7) Serving the game with Node.JS's http-server installed from npm. 8) Launching URL from site running on (7) in Chromium Web Browser as Guest. 9) Error occurs.

Minimal reproduction project

Example project: GodotMonoHelloWorld.Source.zipv

Export template built (1cc1257): godot.javascript.opt.mono.zip

Export template built (df330ce): godot.javascript.opt.mono.zip

Example exported project with the template (1cc1257): GodotMonoHelloWorld.Exported.zip

Example exported project with the template (df330ce) GodotMonoHelloWorld.df330ce.zip

CriDos commented 2 years ago

The problem is probably somewhere in the implementation of the glue version generator (in 3.5 the problem persists): https://github.com/godotengine/godot/blob/3.4/modules/mono/build_scripts/gen_cs_glue_version.py

For official and custom builds of the same version, the glue version is different... If you use the glue version from the official assembly in the custom one, everything works.

nicbillen commented 2 years ago

Hello @CriDos I am running in the same problem.

But for the wasm/javascript export I am also getting "The assembly 'GodotSharp' is out of sync." in the Chrome dev tools.

Do you have a hint, how I can fix it? How can I set the correct version (if it is the same problem)? What is the correct version?

CriDos commented 2 years ago

Hello @nicbillen Try to generate the glue using the official release build of the same version you want and use it in your build.

nicbillen commented 2 years ago

Hello, thank you for your fast answer. I will test it (can take some time) and will share the result.

nicbillen commented 2 years ago

I have now solved it in another way (maybe the explanation can help other people with the same problem).

I have compiled one glue version for Windows and one for Linux/Web/Javascript. For the generated Windows version, there was a version number in the file "mono_glue.gen.cpp" available (I searched for "uint32_t get_cs_glue_version() { return ").

In the Linux version, the version number in the file "mono_glue.gen.cpp" was:

uint32_t get_cs_glue_version() { return 0; }

Windows value:

uint32_t get_cs_glue_version() { return 1666356653; }

The Windows value (1666356653) can be another number in another build. It is just a timestamp.

Replacing 0 with 1666356653 in the Linux/Web/Javascript version and using this glue for template compilation, solved the problem.

@CriDos many thanks for your help