-
Notifications
You must be signed in to change notification settings - Fork 38
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
GDKotlin Rework: Module initialization #609
GDKotlin Rework: Module initialization #609
Conversation
ba502c2
to
2373302
Compare
e83700b
to
2fe7b51
Compare
8e5ff25
to
839fbb9
Compare
e983afe
to
d3043bb
Compare
cef05e5
to
e48e07c
Compare
839fbb9
to
b561986
Compare
e48e07c
to
ad08b33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job. Not much to complain.
Just briefly tested build, startup and reloading on the macos arm editor.
A simple error case was also tested.
#endif | ||
|
||
#ifdef DEBUG_ENABLED | ||
void GDKotlin::validate_state() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably move this to a separate class no? we could centralize the checks once we add more. Also for once we add back the editor plugin we could do some checks there.
But I'm also fine if we think about this later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to keep it there. GDKotlin is now responsible for all the high level management of the module, so it's right where it should be.
Also I don't recommend having checks in the editor plugin, because it means we won't be able to use them when doing an export debug.
c514de1
to
c173356
Compare
78a1ccb
to
d46573a
Compare
c173356
to
7e7e6e8
Compare
747f1f1
to
e92b2f5
Compare
e92b2f5
to
23cb5d3
Compare
* Initialize GDKotlin outside language. * Add proper initialization step for the module and remove many explicit crashes * Create JvmScriptManager * Remove NO_USE_STDLIB preprocessor, it has been removed from the engine since Godot 4
* Initialize GDKotlin outside language. * Add proper initialization step for the module and remove many explicit crashes * Create JvmScriptManager * Remove NO_USE_STDLIB preprocessor, it has been removed from the engine since Godot 4
* Initialize GDKotlin outside language. * Add proper initialization step for the module and remove many explicit crashes * Create JvmScriptManager * Remove NO_USE_STDLIB preprocessor, it has been removed from the engine since Godot 4
* Initialize GDKotlin outside language. * Add proper initialization step for the module and remove many explicit crashes * Create JvmScriptManager * Remove NO_USE_STDLIB preprocessor, it has been removed from the engine since Godot 4
Make the module more resilient to invalid states. Many of the previous explicit crashes got replaced by errors that won't stop the engine execution.
If something goes wrong somewhere in the initialization of the module, a helpful message will appear on-screen before falling back to a Godot with only JVM placeholders.
In debug/tool mode, it's even possible to start the game using JVM scripts that are not built yet. In such case, the script is just not created and only the naked native object will remain (Errors are still thrown in such cases).
GDKotlin got explicit initialization states and a custom error message exists for almost each of them (when the cause is likely a basic one) in case an issue was encountered.
If the final state is invalid, GDkotlin will be immediately freed and unloaded. The languages and resource loader are still registered to Godot, even in the case of an invalid state, so users can manipulate JVM scripts in the editor without a JAVA_HOME, embedded JRE, boostrap.jar or main.jar (They will have an alert appearing on-screen when the engine starts).
Note that the last part of the initialization still has to be done in GdjLanguage. This final step fetches all the Jvm Scripts from Kotlin to C++ as well as sending all method pointers from C++ to Kotlin.
This latter detail matters because this operation requires all classes to be initialized in Godot, so we can't do it as part of the module initialization itself, even using the latest initialization enum value in it. Sadly Godot doesn't have a "afterAll" phase for module initialization.