-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Register Engine, OS, ProjectSettings, and Time singletons in time for INITIZATION_LEVEL_CORE
#98862
Register Engine, OS, ProjectSettings, and Time singletons in time for INITIZATION_LEVEL_CORE
#98862
Conversation
3364252
to
47764c7
Compare
47764c7
to
0ff3cc0
Compare
Thanks! I'm all for this change at a high-level: it would solve a number of long-running issues that many folks have had with GDExtension. I linked to some of the old issues where this was discussion in a comment on the proposal. It's unfortunate that this requires so many little changes throughout Skimming through the changes, they seem fine to me. |
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 tested this with some GDExtensions on both Linux and Android, including actually using the ProjectSettings
singleton in INITIALIZATION_LEVEL_CORE
in the 'godot_openxr_vendors' extension (the use-case there is to not request OpenXR extensions at all if certain project settings aren't enabled -- currently, we have to always request them, but then just avoid using them).
Aside from my note below about a warning, it seemed to work fine in my testing!
if (!OS::get_singleton()->_verbose_stdout) { // Not manually overridden. | ||
OS::get_singleton()->_verbose_stdout = GLOBAL_GET("debug/settings/stdout/verbose_stdout"); | ||
} |
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.
When testing this locally, I'm getting this warning:
WARNING: Property not found: 'debug/settings/stdout/verbose_stdout'.
at: get_setting_with_override (core/config/project_settings.cpp:374)
I think this line needs to also get moved up here:
GLOBAL_DEF("debug/settings/stdout/verbose_stdout", false);
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 have moved the "debug/settings/stdout/" settings registrations earlier, as you suggested.
That is probably my biggest concern with this. I traced all the affected code-paths I could find and I have a GDExtension+project that tests the loading, but I only have a PC and an older Mac to test on. I can clean up my test project and share it here if that would help people with their review, but, even if those tests pass on all devices, I'd still be worried about edge-cases. All that is to say: I am fine waiting until the next version in order to ensure 4.4's stability. |
0ff3cc0
to
1ae91a2
Compare
The default for the XR project settings are not set until shortly before Most of those look safe to move earlier, but I have avoided touching them because it would affect many more parts of the Engine (e.g., many |
These are project settings coming from the GDExtension, not from Godot. So, it worked fine in my testing :-) |
1ae91a2
to
2d01822
Compare
Discussed at GDExtension meeting: we think this one will improve this long-standing issue with GDExtension. It could cause subtle bugs that we won't notice until later, so it probably makes sense to merge early in the 4.4 cycle, and we can partially revert or fix issues as the come up before release. |
Not sure if this would be a big deal in practice. However, we may still want to have an early |
Besides my little two comments, overall this looks good and indeed a good tradeoff between benefit and risk of regressions. |
2d01822
to
d2e87cf
Compare
d2e87cf
to
48fbe41
Compare
Thank you for the review! I've implemented the verbose-debug warning for I've also adjusted the fix from #99149 since this PR calls |
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.
Leaving my approval as there isn't anything else I can suggest to improve this and looks good enough to me for a merge now it's still early in the release cycle and seeing how it goes.
Disclaimers: I haven't tested it myself and my approval is notwithstanding there may still be outstanding suggestions or concerns from other maintainers.
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.
Codestyle checks out
Thanks! Congratulations on your first merged contribution! 🎉 |
INITIZATION_LEVEL_CORE
INITIZATION_LEVEL_CORE
This PR registers the
Engine
,ProjectSettings
,OS
, andTime
singletons to ClassDB earlier so that GDExtensions can access them duringINITIALIZATION_LEVEL_CORE
. Previously, these were only accessible inINITIALIZATION_LEVEL_SCENE
and later.Addresses GIP#9134.
This is done by:
GDREGISTER_CLASS
and callingEngine::add_singleton
for the 4 singletons beforeregister_core_extensions()
.Engine::set_project_manager_hint
.TextServerManager::get_singleton
inOS_Windows::get_system_font_path_for_text
to prevent a crash since Windows needs theTextServerManager
to get the text direction, which is not created until afterINITIALIZATION_LEVEL_CORE
.Caveats:
While the exposed singleton methods are all safe to call, they may not return the expected value if they depend on later setup. These exceptions include:
GLOBAL_DEF
, etc. calls for project settings unrelated to the 4 singletons is mostly untouched, meaning many defaults are not set until afterINITIALIZATION_LEVEL_CORE
(e.g.,rendering/*
settings fromRenderingServer::init()
).OS::has_feature
will still return false for any server feature untilRenderingServer
has been created.OS_Windows::get_system_font_path_for_text
depends on theTextServer
and will return the empty string until it is created.Notes on dependencies and code-paths of exposed singleton methods: [Google Sheets Link]