godotengine / godot

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

Exported mono game only works on Windows; HTML5 crashes, macOS has graphic issues and/or locks up #57455

Open Krumelur opened 2 years ago

Krumelur commented 2 years ago

Godot version

3.5 beta 1 and 3.4 (stable)

System information

macOS Monterey 12.1 on MacBook Air M1 (8 cores, 16GB RAM)

Issue description

I'm using Godot Mono to build a 2d pixel game. It works fine in the editor and when exporting to Windows (Desktop).

Here's a screenshot of the game running correctly on Windows:

screeny

HTML

Exporting to HTML works until the player moves into a new room (click any door) and I can see the following error. Same is true when running the game from the editor, using "Run in browser"

[Log] Say: kitchen (tmp_js_export.js, line 347)
[Error] ERROR: Condition "!tclass" is true. Returned: ManagedType()
    onPrintError (tmp_js_export.js:362)
    put_char (tmp_js_export.js:9:25034)
    write (tmp_js_export.js:9:24201)
    write (tmp_js_export.js:9:56848)
    doWritev (tmp_js_export.js:9:76649)
    _fd_write (tmp_js_export.js:9:214498)
    wasm-stub
    <?>.wasm-function[__stdio_write]
    <?>.wasm-function[__vfprintf_internal]
    <?>.wasm-function[vfprintf]
    <?>.wasm-function[StdLogger::logv(char const*, void*, bool)]
    <?>.wasm-function[Logger::logf_error(char const*, ...)]
    <?>.wasm-function[Logger::log_error(char const*, char const*, int, char const*, char const*, Logger::ErrorType)]
    <?>.wasm-function[CompositeLogger::log_error(char const*, char const*, int, char const*, char const*, Logger::ErrorType)]
    <?>.wasm-function[_err_print_error(char const*, char const*, int, char const*, char const*, ErrorHandlerType)]
    <?>.wasm-function[_err_print_error(char const*, char const*, int, char const*, ErrorHandlerType)]
    <?>.wasm-function[ManagedType::from_class(_MonoClass*)]
    <?>.wasm-function[GDMonoMarshal::mono_object_to_variant(_MonoObject*)]
    <?>.wasm-function[godot_icall_2_665(MethodBind*, Object*, _MonoString*, _MonoArray*)]
    <?>.wasm-function[do_icall]
    <?>.wasm-function[do_icall_wrapper]
    <?>.wasm-function[interp_exec_method_full]
    <?>.wasm-function[interp_runtime_invoke]
    <?>.wasm-function[mono_jit_runtime_invoke]
    <?>.wasm-function[do_runtime_invoke]
    <?>.wasm-function[mono_runtime_try_invoke]
    <?>.wasm-function[mono_runtime_invoke]
    <?>.wasm-function[GDMonoUtils::runtime_invoke(_MonoMethod*, void*, void**, _MonoException**)]
    <?>.wasm-function[GDMonoMethod::invoke(_MonoObject*, Variant const**, _MonoException**) const]
    <?>.wasm-function[CSharpInstance::_call_multilevel(_MonoObject*, StringName const&, Variant const**, int)]
    <?>.wasm-function[CSharpInstance::call_multilevel(StringName const&, Variant const**, int)]
    <?>.wasm-function[Object::call_multilevel(StringName const&, Variant const**, int)]
    <?>.wasm-function[SceneTree::_call_input_pause(StringName const&, StringName const&, Ref<InputEvent> const&)]
    <?>.wasm-function[Viewport::input(Ref<InputEvent> const&)]
    <?>.wasm-function[Viewport::_vp_input(Ref<InputEvent> const&)]
    <?>.wasm-function[MethodBind1<Ref<InputEvent> const&>::call(Object*, Variant const**, int, Variant::CallError&)]
    <?>.wasm-function[Object::call(StringName const&, Variant const**, int, Variant::CallError&)]
    <?>.wasm-function[Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&)]
    <?>.wasm-function[SceneTree::call_group_flags(unsigned int, StringName const&, StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&)]
    <?>.wasm-function[SceneTree::input_event(Ref<InputEvent> const&)]
    <?>.wasm-function[InputDefault::_parse_input_event_impl(Ref<InputEvent> const&, bool)]
    <?>.wasm-function[InputDefault::parse_input_event(Ref<InputEvent> const&)]
    <?>.wasm-function[OS_JavaScript::mouse_button_callback(int, int, double, double, int)]
    wasm-stub
    (anonyme Funktion)
    button_cb (tmp_js_export.js:9:283538)
    button_cb

macOS

Exporting to macOS will result in a running app, however the player cannot move around because the whole level is messed up. I can still click the "push" icon in the action bar on the left. It reacts to a click. Means: the game is running but not as expected. It looks as if parts of the code haven't been executed. As I can see two player characters, I assume it never gets to the point where it finishes intializing the game.

macos

Here are logs generated by the game from start until to the point where it's running. I can tell it does still react because the messages about reducing and increasing the framerate when focus is lost and recovered, but that's all it does.

2022-01-30_19.18.38_77400.log godot.log

Steps to reproduce

HTML: Export the game to HTML5 or run from browser. For HTML, click on any door, see the player move into the new room, click once more and the game locks up and the error above pops up in the console.

For macOS, simply start the exported app.

Minimal reproduction project

I can provide a copy of the game on request but don't want to upload the full project here. Please contact me at rene.ruppert@gmail.com or here in this issue and I can send a link to download the project.

akien-mga commented 2 years ago

That's a pretty weird issue, and I'm not sure what Godot components could have such impact on cross-platform compatibility - aside from Mono itself, if you're using some language features or plugins which create problems on some OSes.

I would suggest trying to make a minimal reproduction project by stripping the project down to the minimum content that triggers this kind of bug. Assuming that you have access to macOS to test and that the bug is reproducible in the main scene, you can remove everything not used in the main scene, then remove stuff used by the main scene one by one to find out what triggers the bug (probably a script, maybe using some kind of threading).

bruvzg commented 2 years ago

... libmono-native.dylib not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Seems like macOS export is signed with Hardened runtime enabled and ad-hoc signature, this is not supported, and prevents some mono libs from loading.

In 4.0, Hardened runtime is auto disabled when ad-hoc signature is used (see #56665), ~but this change is not back-ported to 3.x~ it's also in 3.x, but was added after 3.5 beta 1 release.

You should disable Harderned runtime in the export options manually or use a proper, Apple issued signature.

Krumelur commented 2 years ago

@bruvzg Unchecking "hardened runtime" fixed my macOS problem! You're my hero!

yume-chan commented 1 year ago

I'm using Godot 3.5.2 stable and I had a similar Condition "!tclass" is true. Returned: ManagedType() error when exporting for Web (no error for Windows and Android). I found I need to change this:

- _tween.TweenProperty(parent, "mouse_filter", MouseFilterEnum.Ignore, 0f);
+ _tween.TweenProperty(parent, "mouse_filter", (int)MouseFilterEnum.Ignore, 0f);

Maybe caused by Mono itself?