godotengine / godotengine/godot-cpp
Crash because ___init_method_bindings is not reliable
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
Ok this is a very very very annoying problem. It used to be so that we would lazy bind function pointers. Now this is part of the generation code and we call ___init_method_bindings on every class when the library initialises.
I have two problems with this.
First off all, the ARVR drivers are implemented as singletons, there is no guarantee when trying to use Godot classes that ___init_method_bindings has already been called for that class. This is called from nativescript_init which is called when godot_nativescript_init is called in your plugin. The problem is that godot_nativescript_init only gets called the first time you actually try and load a .gdns file. It is not uncommon for ARVR drivers to not have any of those.
This leads up to the crash.
Second reason I'm not a fan is that Godot has over 1200 classes. That means when my module loads correctly, I'm caching function pointers for over 1200 classes, when I have multiple modules, we're doing this multiple times. In reality I may end up using maybe 10 of those classes at maximum?
The lazy binding approach was way better than the new approach IMHO.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.