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

println seems to prevent proper App exit #3334

Closed
Z35hLy48k opened this issue Dec 15, 2021 · 8 comments
Closed

println seems to prevent proper App exit #3334

Z35hLy48k opened this issue Dec 15, 2021 · 8 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@Z35hLy48k
Copy link

Z35hLy48k commented Dec 15, 2021

Issue Encountered:

Trying to exit the game with exit.send(AppExit).
The window closes but the program's process is still running and terminal window hangs.

After removing all println() from the code, the App exits properly.

Code that might help to reproduce :

fn quit(
    keys: Res<Input<KeyCode>>,
    mut exit: EventWriter<AppExit>
) {
    if keys.pressed(KeyCode::LControl) && keys.pressed(KeyCode::C) {
        println!("Exiting...");
        exit.send(AppExit);
    }
}

Bevy 0.5.0
OS: Linux

@DJMcNab
Copy link
Member

DJMcNab commented Dec 15, 2021

Are you able to reproduce on main? I can't point to any specific reason this would fail, and indeed this seems really strange.

Maybe something is holding a lock on stdout? Do any of the prints happen?

@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Dec 15, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Dec 15, 2021

For me

diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs
index cefce614..54cb40a9 100644
--- a/examples/2d/contributors.rs
+++ b/examples/2d/contributors.rs
@@ -1,4 +1,4 @@
-use bevy::{prelude::*, utils::HashSet};
+use bevy::{prelude::*, utils::HashSet, app::AppExit};
 use rand::{prelude::SliceRandom, Rng};
 use std::{
     env::VarError,
@@ -15,9 +15,20 @@ fn main() {
         .add_system(move_system)
         .add_system(collision_system)
         .add_system(select_system)
+        .add_system(quit)
         .run();
 }
 
+fn quit(
+    keys: Res<Input<KeyCode>>,
+    mut exit: EventWriter<AppExit>
+) {
+    if keys.pressed(KeyCode::LControl) && keys.pressed(KeyCode::C) {
+        println!("Exiting...");
+        exit.send(AppExit);
+    }
+}
+
 // Store contributors in a collection that preserves the uniqueness
 type Contributors = HashSet<String>;

works just fine as of add1818. What did you do to reproduce it @DJMcNab?

@Z35hLy48k
Copy link
Author

I couldn't reproduce on another pc !

@Z35hLy48k
Copy link
Author

Z35hLy48k commented Dec 15, 2021

Do any of the prints happen?

Yes they do happen!

This might be a minor issue that I randomly encountered after all !

@alice-i-cecile
Copy link
Member

I'm going to close this out then: if anyone else encounters this or can reproduce we'll reopen it :)

@bzar
Copy link

bzar commented Jan 23, 2022

Hi, encountering this as well on Bevy 0.6. Removing printlns makes my pong exit cleanly, reintroducing them keeps the process running after exit.

EDIT: Actually, now encountering it even without the printlns. Ignore this report.

@jakoschiko
Copy link

jakoschiko commented Aug 14, 2022

The window closes but the program's process is still running and terminal window hangs.

I have the same problem without any println. I'm using Arch Linux and bevy 0.8. Is there an issue that addresses this problem?

@BorisBoutillier
Copy link
Contributor

@jakoschiko is it similar to #5524 ?

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 S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

7 participants