Skip to content
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

Nested Windows can have surprisingly overlapping ids #5573

Open
JaniM opened this issue Jan 2, 2025 · 1 comment
Open

Nested Windows can have surprisingly overlapping ids #5573

JaniM opened this issue Jan 2, 2025 · 1 comment
Labels
bug Something is broken

Comments

@JaniM
Copy link

JaniM commented Jan 2, 2025

Describe the bug
The following code crashes instantly. I believe the second id overlaps with

let interact_id = layer_id.id.with("move");
. If you replace "move" with anything else, everything works.

To Reproduce

let id = egui::Id::new("foo");
egui::Window::new("Wow").id(id).show(ctx, |_ui| {
    egui::Window::new("Bar")
        .id(id.with("move"))
        .show(ctx, |_ui| {});
});

Expected behavior
No crash.

Desktop (please complete the following information):

  • OS: MacOS, eframe
@JaniM JaniM added the bug Something is broken label Jan 2, 2025
@MeGaGiGaGon
Copy link
Contributor

(Using egui-miniquad patched to work with egui 0.30 since it's the only backend that consistently works on my machine.)

Since the actual error wasn't mentioned, it is

thread 'main' panicked at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163:17:
Widget 8AD1 changed layer_id during the frame from LayerId { Middle 2824 } to LayerId { Middle 8AD1 }
Full error
thread 'main' panicked at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163:17:
Widget 8AD1 changed layer_id during the frame from LayerId { Middle 2824 } to LayerId { Middle 8AD1 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163:17:
Widget 8AD1 changed layer_id during the frame from LayerId { Middle 2824 } to LayerId { Middle 8AD1 }
stack backtrace:
   0:     0x7ff6e2ee7cfd - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff6e2ee7cfd - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff6e2ee7cfd - std::sys_common::backtrace::_print_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:68
   3:     0x7ff6e2ee7cfd - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:44
   4:     0x7ff6e2efb449 - core::fmt::rt::Argument::fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\fmt\rt.rs:165
   5:     0x7ff6e2efb449 - core::fmt::write
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\fmt\mod.rs:1168
   6:     0x7ff6e2ee5a61 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\io\mod.rs:1835
   7:     0x7ff6e2ee7ad6 - std::sys_common::backtrace::print
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:34
   8:     0x7ff6e2ee94c8 - std::panicking::default_hook::closure$1
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:271
   9:     0x7ff6e2ee9176 - std::panicking::default_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:298
  10:     0x7ff6e2ee99f8 - std::panicking::rust_panic_with_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:795
  11:     0x7ff6e2ee98b7 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:664
  12:     0x7ff6e2ee83ef - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:171
  13:     0x7ff6e2ee9568 - std::panicking::begin_panic_handler
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
  14:     0x7ff6e2f03014 - core::panicking::panic_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
  15:     0x7ff6e2d06d5c - egui::widget_rect::WidgetRects::insert
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163
  16:     0x7ff6e2ce9b8b - egui::context::impl$13::create_widget::closure$1
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1164
  17:     0x7ff6e2ce4184 - egui::context::Context::write<tuple$<>,egui::context::impl$13::create_widget::closure_env$1>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:775
  18:     0x7ff6e2ce99eb - egui::context::Context::create_widget
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1158
  19:     0x7ff6e2cab90e - egui::ui::Ui::remember_min_rect
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:1115
  20:     0x7ff6e2cad60c - egui::ui::impl$12::drop
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:3011
  21:     0x7ff6e2c6199f - core::ptr::drop_in_place<egui::ui::Ui>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ptr\mod.rs:542
  22:     0x7ff6e2ca9b2d - egui::ui::Ui::new
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:197
  23:     0x7ffd1809f540 - _CxxFrameHandler3
  24:     0x7ffd18093a86 - is_exception_typeof
  25:     0x7ffd1809ea14 - _C_specific_handler
  26:     0x7ffd18092c94 - is_exception_typeof
  27:     0x7ffd1809f351 - _CxxFrameHandler3
  28:     0x7ffd2a43293f - _chkstk
  29:     0x7ffd2a3c0939 - RtlUnwindEx
  30:     0x7ffd1809eeda - _C_specific_handler
  31:     0x7ffd180918e5 - is_exception_typeof
  32:     0x7ffd18091d00 - is_exception_typeof
  33:     0x7ffd18092d90 - is_exception_typeof
  34:     0x7ffd1809f351 - _CxxFrameHandler3
  35:     0x7ffd2a4328bf - _chkstk
  36:     0x7ffd2a3e2554 - RtlRaiseException
  37:     0x7ffd2a3e22a7 - RtlRaiseException
  38:     0x7ffd27ecb699 - RaiseException
  39:     0x7ffd18095267 - CxxThrowException
  40:     0x7ff6e2eed040 - panic_unwind::real_imp::panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\panic_unwind\src\seh.rs:353
  41:     0x7ff6e2eed040 - panic_unwind::__rust_start_panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\panic_unwind\src\lib.rs:108
  42:     0x7ff6e2ee9d95 - std::panicking::rust_panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:847
  43:     0x7ff6e2ee9a81 - std::panicking::rust_panic_with_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:817
  44:     0x7ff6e2ee98b7 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:664
  45:     0x7ff6e2ee83ef - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:171
  46:     0x7ff6e2ee9568 - std::panicking::begin_panic_handler
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
  47:     0x7ff6e2f03014 - core::panicking::panic_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
  48:     0x7ff6e2d06d5c - egui::widget_rect::WidgetRects::insert
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163
  49:     0x7ff6e2ce9b8b - egui::context::impl$13::create_widget::closure$1
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1164
  50:     0x7ff6e2ce4184 - egui::context::Context::write<tuple$<>,egui::context::impl$13::create_widget::closure_env$1>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:775
  51:     0x7ff6e2ce99eb - egui::context::Context::create_widget
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1158
  52:     0x7ff6e2ca993d - egui::ui::Ui::new
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:177
  53:     0x7ff6e2c9380a - egui::containers::area::Prepared::content_ui
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\area.rs:553
  54:     0x7ff6e2c37314 - egui::containers::window::Window::show_dyn<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:523
  55:     0x7ff6e2c36809 - egui::containers::window::Window::show<tuple$<>,testing::impl$1::draw::closure$0::closure$0::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:428
  56:     0x7ff6e2c3edf0 - testing::impl$1::draw::closure$0::closure$0
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:38
  57:     0x7ff6e2c35512 - core::ops::function::FnOnce::call_once<testing::impl$1::draw::closure$0::closure_env$0,tuple$<ref_mut$<egui::ui::Ui> > >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
  58:     0x7ff6e2d0fc7e - alloc::boxed::impl$48::call_once<tuple$<ref_mut$<egui::ui::Ui> >,dyn$<core::ops::function::FnOnce<tuple$<ref_mut$<egui::ui::Ui> >,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2063
  59:     0x7ff6e2c38865 - egui::containers::window::impl$1::show_dyn::closure$7::closure$0::closure$0<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:572
  60:     0x7ff6e2c432a7 - egui::containers::resize::Resize::show<tuple$<>,egui::containers::window::impl$1::show_dyn::closure$7::closure$0::closure_env$0<tuple$<> > >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\resize.rs:300
  61:     0x7ff6e2c3873f - egui::containers::window::impl$1::show_dyn::closure$7::closure$0<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:568
  62:     0x7ff6e2c35538 - core::ops::function::FnOnce::call_once<egui::containers::window::impl$1::show_dyn::closure$7::closure_env$0<tuple$<> >,tuple$<ref_mut$<egui::ui::Ui> > >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
  63:     0x7ff6e2d0fc7e - alloc::boxed::impl$48::call_once<tuple$<ref_mut$<egui::ui::Ui> >,dyn$<core::ops::function::FnOnce<tuple$<ref_mut$<egui::ui::Ui> >,assoc$<Output,tuple$<> > > >,alloc::alloc::Global>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\alloc\src\boxed.rs:2063
  64:     0x7ff6e2cad0cd - egui::ui::Ui::scope_dyn<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:2303
  65:     0x7ff6e2c3f021 - egui::ui::Ui::scope<tuple$<>,egui::containers::window::impl$1::show_dyn::closure$7::closure_env$0<tuple$<> > >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:2282
  66:     0x7ff6e2c31f88 - egui::containers::collapsing_header::CollapsingState::show_body_unindented<tuple$<>,egui::containers::window::impl$1::show_dyn::closure$7::closure_env$0<tuple$<> 
> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\collapsing_header.rs:236
  67:     0x7ff6e2c37e52 - egui::containers::window::impl$1::show_dyn::closure$7<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:563
  68:     0x7ff6e2c3cd80 - egui::context::Context::with_accessibility_parent<enum2$<core::option::Option<tuple$<> > >,egui::containers::window::impl$1::show_dyn::closure_env$7<tuple$<> > > 
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:3262
  69:     0x7ff6e2c3750d - egui::containers::window::Window::show_dyn<tuple$<> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:532
  70:     0x7ff6e2c3670c - egui::containers::window::Window::show<tuple$<>,testing::impl$1::draw::closure$0::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\window.rs:428
  71:     0x7ff6e2c3ed2a - testing::impl$1::draw::closure$0
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:37
  72:     0x7ff6e2c3b70a - egui_miniquad::impl$0::run::closure$0<testing::impl$1::draw::closure_env$0>
                               at C:\Users\GiGaGon\Desktop\rust_projects\egui-miniquad\src\lib.rs:190
  73:     0x7ff6e2c3cf13 - egui::context::Context::run<egui_miniquad::impl$0::run::closure_env$0<testing::impl$1::draw::closure_env$0> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:830
  74:     0x7ff6e2c3b045 - egui_miniquad::EguiMq::run<testing::impl$1::draw::closure_env$0>
                               at C:\Users\GiGaGon\Desktop\rust_projects\egui-miniquad\src\lib.rs:188
  75:     0x7ff6e2c3f61a - testing::impl$1::draw
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:35
  76:     0x7ff6e2c3c225 - miniquad::native::windows::run<testing::main::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\miniquad-0.4.0\src\native\windows.rs:894
  77:     0x7ff6e2c3382b - miniquad::start<testing::main::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\miniquad-0.4.0\src\lib.rs:285
  78:     0x7ff6e2c3f88d - testing::main
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:90
  79:     0x7ff6e2c3566b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
  80:     0x7ff6e2c31e3e - core::hint::black_box
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\hint.rs:338
  81:     0x7ff6e2c31e3e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\sys_common\backtrace.rs:155
  82:     0x7ff6e2c3db81 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\rt.rs:159
  83:     0x7ff6e2ee2e5e - std::rt::lang_start_internal
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\rt.rs:141
  84:     0x7ff6e2c3db5a - std::rt::lang_start<tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\rt.rs:158
  85:     0x7ff6e2c3f8e9 - main
  86:     0x7ff6e2f00f10 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  87:     0x7ff6e2f00f10 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  88:     0x7ffd29097374 - BaseThreadInitThunk
  89:     0x7ffd2a3dcc91 - RtlUserThreadStart

Note that the crash only happens when you use two Windows. If you use most other things that take an Id, it will instead display the usual warnings. Ie

let id = egui::Id::new("foo");
egui::Window::new("Wow").id(id).show(ctx, |ui| {
    ui.interact(egui::Rect::ZERO, id.with("move"), egui::Sense::click());
});

image
The crash also isn't specific to Windows, it's actually Areas that cause the crash (and Windows are based on Areas).

let id = egui::Id::new("foo");
egui::Area::new(id).show(ctx, |ui| {
    egui::Area::new(id.with("move")).show(ctx, |_|{});
});
Full error with Areas
thread 'main' panicked at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163:17:
Widget 8AD1 changed layer_id during the frame from LayerId { Middle 2824 } to LayerId { Middle 8AD1 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163:17:
Widget 8AD1 changed layer_id during the frame from LayerId { Middle 2824 } to LayerId { Middle 8AD1 }
stack backtrace:
   0:     0x7ff64d62516d - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff64d62516d - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff64d62516d - std::sys_common::backtrace::_print_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:68
   3:     0x7ff64d62516d - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:44
   4:     0x7ff64d6388b9 - core::fmt::rt::Argument::fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\fmt\rt.rs:165
   5:     0x7ff64d6388b9 - core::fmt::write
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\fmt\mod.rs:1168
   6:     0x7ff64d622ed1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\io\mod.rs:1835
   7:     0x7ff64d624f46 - std::sys_common::backtrace::print
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:34
   8:     0x7ff64d626938 - std::panicking::default_hook::closure$1
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:271
   9:     0x7ff64d6265e6 - std::panicking::default_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:298
  10:     0x7ff64d626e68 - std::panicking::rust_panic_with_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:795
  11:     0x7ff64d626d27 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:664
  12:     0x7ff64d62585f - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:171
  13:     0x7ff64d6269d8 - std::panicking::begin_panic_handler
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
  14:     0x7ff64d640484 - core::panicking::panic_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
  15:     0x7ff64d47edec - egui::widget_rect::WidgetRects::insert
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163
  16:     0x7ff64d4244ab - egui::context::impl$13::create_widget::closure$1
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1164
  17:     0x7ff64d4200f4 - egui::context::Context::write<tuple$<>,egui::context::impl$13::create_widget::closure_env$1>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:775
  18:     0x7ff64d42430b - egui::context::Context::create_widget
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1158
  19:     0x7ff64d48604e - egui::ui::Ui::remember_min_rect
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:1115
  20:     0x7ff64d48615c - egui::ui::impl$12::drop
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:3011
  21:     0x7ff64d3e317f - core::ptr::drop_in_place<egui::ui::Ui>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ptr\mod.rs:542
  22:     0x7ff64d485a9d - egui::ui::Ui::new
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:197
  23:     0x7ffd1809f540 - _CxxFrameHandler3
  24:     0x7ffd18093a86 - is_exception_typeof
  25:     0x7ffd1809ea14 - _C_specific_handler
  26:     0x7ffd18092c94 - is_exception_typeof
  27:     0x7ffd1809f351 - _CxxFrameHandler3
  28:     0x7ffd2a43293f - _chkstk
  29:     0x7ffd2a3c0939 - RtlUnwindEx
  30:     0x7ffd1809eeda - _C_specific_handler
  31:     0x7ffd180918e5 - is_exception_typeof
  32:     0x7ffd18091d00 - is_exception_typeof
  33:     0x7ffd18092d90 - is_exception_typeof
  34:     0x7ffd1809f351 - _CxxFrameHandler3
  35:     0x7ffd2a4328bf - _chkstk
  36:     0x7ffd2a3e2554 - RtlRaiseException
  37:     0x7ffd2a3e22a7 - RtlRaiseException
  38:     0x7ffd27ecb699 - RaiseException
  39:     0x7ffd18095267 - CxxThrowException
  40:     0x7ff64d62a4b0 - panic_unwind::real_imp::panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\panic_unwind\src\seh.rs:353
  41:     0x7ff64d62a4b0 - panic_unwind::__rust_start_panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\panic_unwind\src\lib.rs:108
  42:     0x7ff64d627205 - std::panicking::rust_panic
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:847
  43:     0x7ff64d626ef1 - std::panicking::rust_panic_with_hook
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:817
  44:     0x7ff64d626d27 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:664
  45:     0x7ff64d62585f - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\sys_common\backtrace.rs:171
  46:     0x7ff64d6269d8 - std::panicking::begin_panic_handler
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
  47:     0x7ff64d640484 - core::panicking::panic_fmt
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
  48:     0x7ff64d47edec - egui::widget_rect::WidgetRects::insert
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\widget_rect.rs:163
  49:     0x7ff64d4244ab - egui::context::impl$13::create_widget::closure$1
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1164
  50:     0x7ff64d4200f4 - egui::context::Context::write<tuple$<>,egui::context::impl$13::create_widget::closure_env$1>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:775
  51:     0x7ff64d42430b - egui::context::Context::create_widget
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:1158
  52:     0x7ff64d4858ad - egui::ui::Ui::new
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\ui.rs:177
  53:     0x7ff64d4115ba - egui::containers::area::Prepared::content_ui
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\area.rs:553
  54:     0x7ff64d3a4c78 - egui::containers::area::Area::show<tuple$<>,testing::impl$1::draw::closure$0::closure$0::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\area.rs:367
  55:     0x7ff64d3a9cd7 - testing::impl$1::draw::closure$0::closure$0
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:38
  56:     0x7ff64d3a4a59 - egui::containers::area::Area::show<tuple$<>,testing::impl$1::draw::closure$0::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\containers\area.rs:368
  57:     0x7ff64d3a9c58 - testing::impl$1::draw::closure$0
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:37
  58:     0x7ff64d3a790a - egui_miniquad::impl$0::run::closure$0<testing::impl$1::draw::closure_env$0>
                               at C:\Users\GiGaGon\Desktop\rust_projects\egui-miniquad\src\lib.rs:190
  59:     0x7ff64d3a88f3 - egui::context::Context::run<egui_miniquad::impl$0::run::closure_env$0<testing::impl$1::draw::closure_env$0> >
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\egui-0.30.0\src\context.rs:830
  60:     0x7ff64d3a7245 - egui_miniquad::EguiMq::run<testing::impl$1::draw::closure_env$0>
                               at C:\Users\GiGaGon\Desktop\rust_projects\egui-miniquad\src\lib.rs:188
  61:     0x7ff64d3a9fca - testing::impl$1::draw
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:35
  62:     0x7ff64d3a81d5 - miniquad::native::windows::run<testing::main::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\miniquad-0.4.0\src\native\windows.rs:894
  63:     0x7ff64d3a2abb - miniquad::start<testing::main::closure_env$0>
                               at C:\Users\GiGaGon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\miniquad-0.4.0\src\lib.rs:285
  64:     0x7ff64d3aa23d - testing::main
                               at C:\Users\GiGaGon\Desktop\rust_projects\testing\src\main.rs:88
  65:     0x7ff64d3a423b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
  66:     0x7ff64d3a174e - core::hint::black_box
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\hint.rs:338
  67:     0x7ff64d3a174e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\sys_common\backtrace.rs:155
  68:     0x7ff64d3a9021 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\rt.rs:159
  69:     0x7ff64d6202ce - std::rt::lang_start_internal
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\rt.rs:141
  70:     0x7ff64d3a8ffa - std::rt::lang_start<tuple$<> >
                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\std\src\rt.rs:158
  71:     0x7ff64d3aa299 - main
  72:     0x7ff64d63e380 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  73:     0x7ff64d63e380 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  74:     0x7ffd29097374 - BaseThreadInitThunk
  75:     0x7ffd2a3dcc91 - RtlUserThreadStart

The actual crash happens because... Widget x changed layer_id during the frame. The actual crash is from this assert

debug_assert!(
    existing.layer_id == widget_rect.layer_id,
    "Widget {:?} changed layer_id during the frame from {:?} to {:?}",
    widget_rect.id,
    existing.layer_id,
    widget_rect.layer_id
);

And since it's a debug assert, if you run in release mode it doesn't crash, but you can get interesting results if this happens on a Window/Area with content. I know this since I ran into it several times while making my own node graph flavor.

I don't see any way that this could be fully solved, since no matter what Id is used for the Area internals, it has to be based on the given Id, and thus there will always be the possibility of a collision. Maybe the string/source used could be mangled to provide a lower change of collision, but that's about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants