Hello, I’m making a GDExtension with godot-cpp to add support to a new scripting language (Luau with simpler OOP wrapping) using ScriptExtension
and ScriptLanguageExtension
.
I tried making the extension hot reloadable to make my life easier.
I’ve successfully done so with previous extensions, however with this one, the editor crashes after reloading.
Using a debugger on the editor itself (on a build with debug symbols), I was able to see that after unloading the extension, it’s trying to send various notifications (such as window mouse events, or nodes leaving the tree…) to “stale” instances from my unloaded extension. Specifically, ScriptExtension
instances where the ScriptLanguage
instance has been freed when unloading the library, or ScriptInstances
where both the Script
and ScriptLanguage
were freed.
When hot reloading the library, it seems that the editor doesn’t discard all instances of Script
and ScriptInstance
that were created and still tries to use them as if nothing happened.
However:
- the code for them has been unloaded and reloaded
- the
ScriptLanguage
instance has been freed and recreated as part of my teardown / init functions.
I would expect Godot to discard recreate every Script
and ScriptInstance
from my extension after hot reloading.
Is it a known limitation / oversight / corner case of GDExtension hot reloading, or do I need to fix / add something on my end?
Thanks!