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 forgets about GDExtension properties on extension reload, depending on the .gdextension file. #96403

Open
Ivorforce opened this issue Aug 31, 2024 · 3 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)

I have not tested 4.4-dev in-depth yet.

Issue description

The format of the .gdextension file currently affects how 'well' the Godot editor is able to reload a GDExtension.
In the case that it is 'improperly' reloaded, the editor forgets about all properties / functions of the extension. Class names are retained. When the game is launched, it works as expected in all cases.

Example of an error screen:

--- 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".
[...]

SCR-20240831-suol
SCR-20240831-suqj

Cases

At this point, I am reasonably sure I can properly categorize the behavior into 3 camps:

When pointing directly to a .framework bundle, in all cases the editor forgets about the properties after a single click. It probably reloads instantly and fails the reload:

# All these cases behave the same way:
macos/numdot.macos.template_debug.x86_64.framework
./macos/numdot.macos.template_debug.x86_64.framework
res://addons/numdot/macos/numdot.macos.template_debug.x86_64.framework
res://./addons/numdot/macos/numdot.macos.template_debug.x86_64.framework

When pointing to a binary directly, the editor retains knowledge of the properties until the binary is rebuild. Then, it fails the reload:

# All these cases behave the same way:
macos/numdot.macos.template_debug.x86_64.framework/numdot.macos.template_debug.x86_64
res://addons/numdot/macos/numdot.macos.template_debug.x86_64.framework/numdot.macos.template_debug.x86_64
macos/numdot.macos.template_debug.x86_64.dylib
res://addons/numdot/macos/numdot.macos.template_debug.x86_64.dylib

When pointing to the binary directly, using a path that starts with ./, knowledge of the binary is retained. However, changes to the documentation are only reloaded when the editor is unfocused and focused again:

# These cases behave the same way:
./macos/numdot.macos.template_debug.x86_64.framework/numdot.macos.template_debug.x86_64
res://./addons/numdot/macos/numdot.macos.template_debug.x86_64.framework/numdot.macos.template_debug.x86_64
./macos/numdot.macos.template_debug.x86_64.dylib
res://./addons/numdot/macos/numdot.macos.template_debug.x86_64.dylib

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?

@Ivorforce Ivorforce reopened this Oct 16, 2024
@Ivorforce Ivorforce changed the title (macOS) Godot Editor quickly forgets about GDExtension class functions when pointing to .framework in the .gdextension file, rather than to the binary directly (macOS) Godot Editor forgets about GDExtension properties on extension reload. Jan 7, 2025
@Ivorforce Ivorforce changed the title (macOS) Godot Editor forgets about GDExtension properties on extension reload. (macOS) Godot Editor forgets about GDExtension properties on extension reload, depending on the .gdextension file. Jan 7, 2025
@Ivorforce
Copy link
Contributor Author

Alright, I think I have all the information together on this issue that there is to have. I have edited the issue description accordingly.

See also related godotengine/godot-cpp#1681.

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