-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
For v4.3+, switch #[class(tool)]
to use Godot's native "runtime class" feature
#619
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-619 |
a0f8f28
to
c5d5534
Compare
Hello, sorry for commenting on closed PR. I'm experiencing panics on any access to singletons (checked from
Usually this assertion is hit: #[inline(always)]
pub unsafe fn class_servers_api() -> &'static ClassServersMethodTable {
// SAFETY: `get_binding` has the same preconditions as this function.
let binding = unsafe { get_binding() };
debug_assert!(
binding.class_server_method_table.is_initialized(), // <<< THIS ONE!
"cannot fetch classes; init level 'Servers' not yet loaded"
);
// SAFETY: `initialize_class_server_method_table` has been called.
unsafe { binding.class_server_method_table.get_unchecked() }
} |
That problem has been reported on Discord before, but I don't see the relation to this PR? |
Aha, I was curious if the bug was related to tool class behavior. Thanks for checking it out! I think #582 issue is simillar situation with me where crashing on engine resource access after hot reloading, however, I'm not sure if it's exactly the same issue. I've just tested another PR which targets to resolve broken hot reloading by reverting some commit(#628, revert #[inline(always)]
pub unsafe fn class_servers_api() -> &'static ClassServersMethodTable {
let table = &unwrap_ref_unchecked(&BINDING).class_server_method_table;
debug_assert!(
table.is_some(), // <<< Only method name changed ...
"cannot fetch classes; init level 'Servers' not yet loaded"
);
table.as_ref().unwrap_unchecked()
} May I create a separate issue about this? This is pretty big blocker for me developing egui plugin for editor plugin purpose. 😢 |
Yes sure, feel free to open an issue :) Maybe also comment on #628. But in its current form I can't merge that one, we should isolate the issue. |
For Godot 4.0, 4.1 and 4.2, gdext emulates a mode where classes' lifecycle methods are not executed in the editor, unless
#[class(tool)]
is specified or the globaleditor_run_behavior()
is configured.Starting from Godot 4.3, GDExtension provides this feature natively, dubbed "runtime classes" (formerly "gameplay classes").
This has been implemented in godotengine/godot#82554 and merged a few hours ago.
This PR thus conditionally switches to the native implementation, when API 4.3 is targeted.
I briefly tested the functionality with dodge-the-creeps, but it might be that there are still some bugs, as it's hard to write automated tests for this. Let us know in case things don't work as expected.