Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(macOS) Godot Editor quickly forgets about GDExtension class functions when pointing to .framework in the .gdextension file, rather than to the binary directly #96403

Open
Ivorforce opened this issue Aug 31, 2024 · 2 comments

Comments

@Ivorforce
Copy link
Contributor

Ivorforce commented Aug 31, 2024

Tested versions

Reproducible in Godot 4.3.

System information

Godot v4.3.stable - macOS 13.6.7 - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 XT - 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz (16 Threads)

Issue description

When defining a custom GDExtension class, and a static method on it, it is properly registered in the godot editor on first launch.
However, as soon as the game is run for the first time (edit: or sometimes when the window is switched), the editor forgets about the method (though notably, not about the class). This is apparent in the code editor, as well as the documentation page. When the project is reloaded, the methods are available again, until first run.

Notably, the functions can still be called, even though the editor complains:

--- Debugging process stopped ---
  res://main.gd:6 - Parse Error: Static function "test_function()" not found in base "GDScriptNativeClass".
  res://main.gd:6 - Parse Error: Static function "test_function()" not found in base "GDScriptNativeClass".
[...]

Before starting the game:

SCR-20240831-suwt
SCR-20240831-suya

After:

SCR-20240831-suol
SCR-20240831-suqj

Comments

It is possible that this issue is only present in the cpp gdextension (https://github.com/godotengine/godot-cpp/tree/fbbf9ec4efd8f1055d00edb8d926eef8ba4c2cce). I did not test any others.

Steps to reproduce

  1. Create a blank gdextension with https://github.com/godotengine/godot-cpp
  2. Register a static method via godot::ClassDB::bind_static_method("GDExample", D_METHOD("example_function"), &GDExample::example_function);
  3. Open the godot editor
  4. Run the game
  5. Observe the amnesia

Minimal reproduction project (MRP)

https://github.com/Ivorforce/gdextension-staticmethod-amnesia

@Ivorforce
Copy link
Contributor Author

Ivorforce commented Sep 20, 2024

Update: I think I have figured out the cause.

Ever since I updated the macos binaries to be .dylib suffix, the ingame editor is responsive again, and doesn't forget about the classes.

I have created a PR for the template to account for this problem (godotengine/godot-cpp-template#49). However, this PR still needs to stay open, because it's still a bug even if it has a workaround: If the file suffix is incorrect, the extension unloads in the editor (at least on macOS).

@Ivorforce Ivorforce changed the title Godot Editor forgets about gdextension class' static method after first launch (macOS) Godot Editor forgets about GDExtension class functions after first launch when pointing to .framework in the .gdextension file, rather than to the binary directly Oct 4, 2024
@Ivorforce Ivorforce changed the title (macOS) Godot Editor forgets about GDExtension class functions after first launch when pointing to .framework in the .gdextension file, rather than to the binary directly (macOS) Godot Editor quickly forgets about GDExtension class functions when pointing to .framework in the .gdextension file, rather than to the binary directly Oct 4, 2024
@Ivorforce
Copy link
Contributor Author

I cannot reproduce this bug with Godot 4.4-dev3 as well as custom built master branch. It's possible it's been fixed already, just not released in 4.3 yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants