-
Notifications
You must be signed in to change notification settings - Fork 252
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
EguiContexts::ctx_mut
occasionally causes a panic when closing the app.
#212
Comments
I am also seeing this. It looks like |
My guess is that the I think this is kind of a flaw in An alternative temporary fix is to add a run condition to your system. This is a little silly, since you're running the same query twice, but it's a one line change until this gets resolved. // In setup:
app.add_systems(PostUpdate, (
some_system.run_if(egui_has_primary_context),
))
// Elsewhere:
pub fn egui_has_primary_context(
query: Query<(With<bevy_egui::EguiContext>, With<bevy_window::PrimaryWindow>)>,
) -> bool {
!query.is_empty()
} |
Can we have |
Sounds good, I'll add it in the next release. Meanwhile, you can use the workaround suggested by @AntiBlueQuirk or use the following query, as in the |
@mvlabat this did not make it in |
@extrawurst the |
but it does not 🤔 its regular |
@extrawurst is it consistent? Do you have a reproducible example? |
nope not reliable reproducible, just like in the original posters case :( |
its just the first time now that I got it after updating to bevy |
I also have calls to |
This might be a redneck workaround but I noticed that when I quit my app manually via a Quit button, I no longer received the panic messages. The panic messages only occur when I 'X' out the window. So I made this system to intercept the window close event, and close it the same way I do with the Quit button. Now the app never panics on window close.
I'm not smart enough to know why this works, but it does. On Ubtunu 22.04 at least. It doesn't fix whatever the issue is but I found it to be a better workaround vs using try_ctx_mut() in all of my egui systems. |
I can also confirm that this is occurring on fn ui_left_panel(mut contexts: bevy_egui::EguiContexts) {
egui::Area::new("Left".into())
.anchor(egui::Align2::LEFT_CENTER, egui::Vec2::ZERO)
.show(contexts.ctx_mut(), |ui| {
// body
});
} It's easy enough for me to switch to |
This panic occurs intermittently when closing my app. Based on the panic message, I'm assuming that the
EguiContext
for the primary window is being deinitialized before the app fully closes, after which my system is allowed to run, which fails since it's trying to access an uninitialized context.Backtrace:
The text was updated successfully, but these errors were encountered: