#No code after app finishes seems to run.

16 messages · Page 1 of 1 (latest)

north apex
#

Hi! I'm not sure if this is just related to bevy or if it's an idsue with my wm (awesomewm), but when I close the window using the normal method for window managers (which I've checked, and should just send WM_DELETE_WINDOW) bevy prints out the nice normal messages about how there are no windows open, so it exits bevy, but I have a println!() after the app.run(); and it's not printing anything after this.

I'm not sure if this is expected or not

languid geyser
#

Doesn't that come with a big "DON'T USE" warning attached?

quick marsh
#

Despite its appearance at first glance, this is not a perfect replacement for poll_events. For example, this function will not return on Windows or macOS while a window is getting resized, resulting in all application logic outside of the event_handler closure not running until the resize operation ends. Other OS operations may also result in such freezes. This behavior is caused by fundamental limitations in the underlying OS APIs, which cannot be hidden by winit without severe stability repercussions.

You are strongly encouraged to use run, unless the use of this is absolutely necessary.

#

Basically some weird shit can happen, but on the platforms where it's stated to work, it's generally OK to use. I frankly wouldn't rely on it outside of debugging purposes, to ensure maximum compatibility

#

But the main bit is

By default, return_from_run is false and Bevy will use winit’s EventLoop::run() to initiate the event loop. EventLoop::run() will never return but will terminate the process after the event loop exits.

north apex
#

Luckily I actually only want to do this for debugging (I basically want the default running to run a server and 2 clients, but when the main client stops I need to stop the other two processes)

#

Thank you!

#

I guess the proper way to do this would be to run a system and print stuff when there is an AppExit event? But there doesn't seem to ever be any stage in which you ca put AppExit that'll actually register the event before winit finishes your process

#

Oh, I forgot about Last

celest brook
#

Yeah, AppExit should be the event you want. Althought, it's not triggered by things like using task manager and force closing the app or panics

north apex
#

Yeahh, there's no way to intercept a kill signal on Linux anyway, so this is fine, luckily the window manager does the correct thing

#

I just though it was force stopping because it wasn't printing anything after out, but now I now!

north apex
#

I did find a pretty neat solution in the end, I have the second client and the server running as two separate processes, and I just send a message to their stdin, and then I check if they receive "exit" on stdin, and if they do they send an AppExit event in their own apps, and then in the main client I just send these messages, and wait for the processes to complete

#

It's not good enough for a proper solution, as you would have to have a timeout as well, to account for when the extra process just never shuts down, but this is just testing code, so it's fine

young falcon
#

yeah I was going to suggest bash-wrapping the binary if it's just for debugging