kang-sw / gdext-egui

Mozilla Public License 2.0
7 stars 1 forks source link

Tool class Hot-reloading crashes #2

Open kang-sw opened 7 months ago

kang-sw commented 7 months ago

Steps to reproduce

  1. Open ToolTest.tscn scene in editor
  2. Check if EGUI viewports are correctly spwned.
  3. Replace dll(touch effectively refreshes it)
  4. Hot reload => Panics!

Stack frame is:


<omitted>
...

(c:\rustc\07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\std\src\panicking.rs:645)
~gdext_egui_example.dll!core::panicking::panic_fmt() Line 72 (c:\rustc\07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\panicking.rs:72)
[Inline Frame] ~gdext_egui_example.dll!godot_ffi::binding::class_servers_api() Line 225 (c:\Users\ki608\.cargo\git\checkouts\gdext-76630c89719e160c\6614030\godot-ffi\src\binding\mod.rs:225)
~gdext_egui_example.dll!godot_core::gen::classes::display_server::re_export::DisplayServer::window_get_current_screen_full(int self) Line 1204 (c:\Users\ki608\.cargo\git\checkouts\gdext-76630c89719e160c\6614030\godot-core\src\gen\classes\display_server.rs:1204)
~gdext_egui_example.dll!godot_core::gen::classes::display_server::ExWindowGetCurrentScreen::done(godot_core::gen::classes::display_server::ExWindowGetCurrentScreen) Line 2873 (c:\Users\ki608\.cargo\git\checkouts\gdext-76630c89719e160c\6614030\godot-core\src\gen\classes\display_server.rs:2873)
~gdext_egui_example.dll!gdext_egui::context::EguiBridge::viewport_validate(egui::viewport::ViewportId self, enum2$<core::option::Option<tuple$<egui::viewport::ViewportId,egui::viewport::ViewportBuilder>>> id) Line 1020 (e:\naivewild\gdext-egui\src\context.rs:1020)
~gdext_egui_example.dll!gdext_egui::context::EguiBridge::try_start_frame() Line 437 (e:\naivewild\gdext-egui\src\context.rs:437)
~gdext_egui_example.dll!gdext_egui::context::EguiBridge::current_frame() Line 229 (e:\naivewild\gdext-egui\src\context.rs:229)
~gdext_egui_example.dll!gdext_egui_example::impl$23::process(gdext_egui_example::ToolTest * self, double _delta) Line 89 (e:\naivewild\gdext-egui\example\.rust\lib.rs:89)
~gdext_egui_example.dll!gdext_egui_example::impl$25::__virtual_call::function::closure$0(gdext_egui_example::impl$25::__virtual_call::function::closure_env$0 *, godot_ffi::gen::gdextension_interface::__GdextClassInstance * instance_ptr, tuple$<f64> params) Line 68 (e:\naivewild\gdext-egui\example\.rust\lib.rs:68)
~gdext_egui_example.dll!core::ops::function::FnOnce::call_once<gdext_egui_example::impl$25::__virtual_call::function::closure_env$0,tuple$<ptr_mut$<godot_ffi::gen::gdextension_interface::__GdextClassInstance>,tuple$<f64>>>(gdext_egui_example::impl$25::__virtual_call::function::closure_env$0, godot_ffi::gen::gdextension_interface::__GdextClassInstance *, tuple$<f64>) Line 250 (c:\rustc\07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\core\src\ops\function.rs:250)
~gdext_egui_example.dll!godot_core::builtin::meta::signature::impl$19::in_ptrcall<tuple$<>,f64>(godot_ffi::gen::gdextension_interface::__GdextClassInstance * instance_ptr, godot_core::builtin::meta::signature::CallContext * call_ctx, godot_ffi::gen::gdextension_interface::__GdextType * * args_ptr, godot_ffi::gen::gdextension_interface::__GdextType * ret, void(*)(godot_ffi::gen::gdextension_interface::__GdextClassInstance *, tuple$<f64>) func, godot_ffi::godot_ffi::PtrcallType call_type) Line 357 (c:\Users\ki608\.cargo\git\checkouts\gdext-76630c89719e160c\6614030\godot-core\src\builtin\meta\signature.rs:357)
~gdext_egui_example.dll!gdext_egui_example::impl$25::__virtual_call::function(godot_ffi::gen::gdextension_interface::__GdextClassInstance * instance_ptr, godot_ffi::gen::gdextension_interface::__GdextType * * args_ptr, godot_ffi::gen::gdextension_interface::__GdextType * ret) Line 68 (e:\naivewild\gdext-egui\example\.rust\lib.rs:68)

...
<omitted>

It triggers this assertion, after invoking :

    debug_assert!(
        binding.class_server_method_table.is_initialized(),
        "cannot fetch classes; init level 'Servers' not yet loaded"
    );

of this method:

pub unsafe fn class_servers_api() -> &'static ClassServersMethodTable 
kang-sw commented 7 months ago

Continue after issue godot-rust/gdext#629 is resolved

kang-sw commented 7 months ago

Fix for this issue has been merged(godot-rust/gdext#636), should test if this issue won't occur anymore with latest gdext branch.