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

Unable to Close Window and Exit Program on Application Shutdown #12106

Closed
LTstrange opened this issue Feb 25, 2024 · 4 comments
Closed

Unable to Close Window and Exit Program on Application Shutdown #12106

LTstrange opened this issue Feb 25, 2024 · 4 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Regression Functionality that used to work but no longer does. Add a test for this!
Milestone

Comments

@LTstrange
Copy link

Bevy version

Bevy version: 0.13.0

[Optional] Relevant system information

Operating System: Windows 11

What you did

use bevy::prelude::*;

fn main() {
    App::new().add_plugins(DefaultPlugins).run();
}

What went wrong

I encountered an issue where, upon attempting to close the window (either by clicking the close button or using ESC to exit the program), the window and program failed to close properly. Windows eventually displays a "Program not responding" message.

Additional information

The log messages indicate a discrepancy in the sequence of events during shutdown:

2024-02-25T07:09:19.165215Z  INFO bevy_window::system: No windows are open, exiting
2024-02-25T07:09:19.165963Z  INFO bevy_winit::system: Closing window 0v1

The first message suggests that no windows are open, while the second message indicates an attempt to close a window. This discrepancy may prevent the window and program from closing correctly.

Here is the full log:

2024-02-25T07:09:15.624801Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-02-25T07:09:16.176184Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2070 Super", vendor: 4318, device: 7825, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.61", backend: Vulkan }
2024-02-25T07:09:19.165215Z  INFO bevy_window::system: No windows are open, exiting
2024-02-25T07:09:19.165963Z  INFO bevy_winit::system: Closing window 0v1
@LTstrange LTstrange added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Feb 25, 2024
@LTstrange LTstrange changed the title Cloud not Could not close window Feb 25, 2024
@LTstrange LTstrange changed the title Could not close window Unable to Close Window and Exit Program on Application Shutdown Feb 25, 2024
@LTstrange
Copy link
Author

I tested it several times. It happens frequently, but sometimes not.

@TrialDragon TrialDragon added A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled labels Feb 28, 2024
@Selene-Amanita Selene-Amanita added this to the 0.13.1 milestone Mar 3, 2024
@Selene-Amanita
Copy link
Member

Selene-Amanita commented Mar 3, 2024

Happens to me too.

The order discrepency is not a big deal I think because the Window entity is despawned when the window is closed (not sure by which process, doesn't matter), and exit_on_all_closed and despawn_windows (which print the messages) both react to that, the first one sends the AppExit event, the second one just tells winit to actually close the window, the order shouldn't matter.

After some testing, event_loop.exit() never seems to be called, and actually the handle_winit_event function is never called again by the event loop as soon as there is no window, which ironically prevents it from exiting. If you comment out the line winit_windows.remove_window(window); of despawn_windows then it exits normally.

A "hotfix" could be to somehow wait a bit before telling winit to actually close the window (like, putting despawn_windows in the First schedule (tested, it works on the minimal example, but might pose other problems), but there might be a deeper issue here.

@Selene-Amanita Selene-Amanita added the C-Regression Functionality that used to work but no longer does. Add a test for this! label Mar 3, 2024
@inact1v1ty
Copy link
Contributor

This happens on macOS too. Also, it doesn't matter how the application is closed - it hangs if the window is closed, if the AppExit is fired manually, if Control + C pressed in the console, and even if game crashes because of a panic.

@mockersf mockersf modified the milestones: 0.13.1, 0.13.2 Mar 18, 2024
@mockersf mockersf modified the milestones: 0.13.2, 0.13.3 Apr 4, 2024
@JMS55 JMS55 modified the milestones: 0.13.3, 0.14 Apr 25, 2024
@alice-i-cecile
Copy link
Member

I can no longer reproduce on 65e62ba on Windows 11 :) Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Regression Functionality that used to work but no longer does. Add a test for this!
Projects
None yet
Development

No branches or pull requests

7 participants