Properly handle repeated window close requests#14573
Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom Aug 1, 2024
Merged
Properly handle repeated window close requests#14573alice-i-cecile merged 1 commit intobevyengine:mainfrom
alice-i-cecile merged 1 commit intobevyengine:mainfrom
Conversation
8394aee to
4c32750
Compare
4c32750 to
c6d1e60
Compare
alice-i-cecile
approved these changes
Aug 1, 2024
mockersf
pushed a commit
that referenced
this pull request
Aug 2, 2024
# Objective Spamming the window close button on window may trigger a panic. ``` thread 'main' panicked at <Bevy repo>\crates\bevy_ecs\src\system\commands\mod.rs:1320:13: error[B0003]: Could not insert a bundle (of type `bevy_window::window::ClosingWindow`) for entity 0v1#4294967296 because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Encountered a panic when applying buffers for system `bevy_window::system::close_when_requested`! 2024-08-01T15:00:29.742612Z WARN bevy_ecs::world::command_queue: CommandQueue has un-applied commands being dropped. Did you forget to call SystemState::apply? Encountered a panic in system `bevy_app::main_schedule::Main::run_main`! error: process didn't exit successfully: `target\debug\bevy.exe` (exit code: 101) ``` ## Solution Don't panic when trying to insert the `ClosingWindow` component into a entity. ## Testing Found and tested on windows. I haven't checked if this bug happens on linux or macos. For testing I ran this code: ```rust use std::{thread, time::Duration}; use bevy::prelude::*; fn lag() { thread::sleep(Duration::from_millis(300)); } fn main() -> AppExit { App::new() .add_plugins(DefaultPlugins) .add_systems(Update, lag) .run() } ``` Then spammed the window close button. The panic no longer occurs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Spamming the window close button on window may trigger a panic.
Solution
Don't panic when trying to insert the
ClosingWindowcomponent into a entity.Testing
Found and tested on windows. I haven't checked if this bug happens on linux or macos.
For testing I ran this code:
Then spammed the window close button. The panic no longer occurs.