-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Extension class instances constructed in rust cannot be reloaded #543
Comments
Otherwise, we'd need to have an intermediate zombie state (something like
This sounds like the better idea. I can talk to the Godot devs about the feasibility of this.
This doesn't seem to be true in general. For example, if you add Could you describe more clearly what exactly doesn't work? Ideally with a short example. |
Godot hot reloading requires a init method as it uses
The |
This should have been fixed upstream with godotengine/godot#90447. @TitanNano Any chance you can test this with a recent nightly version of Godot? You can download precompiled binaries from this CI or build yourself. If you don't get around it, also fine! 🙂 |
Hi! I ran into the same issues as @TitanNano. I confirm that using Godot's latest nighty build( v4.3.dev.custom_build [6118592c6] for my case), the hot reload work even with Gd instantiated classes. |
Since Godot 4.2 the engine has extension (hot) reloading. During reloading, the engine creates a backup of the class properties that have been exposed to godot and once the extension has been reloaded it recreates the extension parts of all the classes that have been defined by the extension.
Important here is that the engine tries to track all the instances which have been created for an extension class so that they can be reloaded later on. This happens in
ClassDB::instantiate
.Unfortunately when gdext is creating classes from inside rust, it never goes through
ClassDB::instantiate
. It rather creates a new instance of the base class viaClassDB::instantiate
and then assigns the rust instance to that base object viaobject_set_instance
. The engine does not track these assignments as new instances of an extension class.When the extension is then reloaded, none of the class instances are reloaded as the
instance
list of theextension_class
is empty.Trying to follow the code paths of Godot and gdext it appears that
Gd::default_instance()
should not directly callcrate::callbacks::create
but rather callClassDB::instantiate
.Direct access to
crate::callbacks::create_custom
viaGd::from_init_fn
also seems currently problematic, as it bypasses the instance tracking as well.On the other hand, the engine could also move the instance tracking to
ClassDB::set_object_extension_instance
.The text was updated successfully, but these errors were encountered: