-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Don't update app if we're already exiting #13203
Conversation
d2bf08e
to
2bfe288
Compare
It's a warning that ScreenSpaceAmbientOcclusionPlugin will not work on wasm. It won't affect anything unless you're using SSAO, which if off by default. |
It dies after emitting that. I just assumed the warning was connected. I'll still need somebody else to tests it. Both to check if the error is only on my side and because I just can't test test the code if it dies. |
wasm is kinda broken on main until #13210 lands. When I rebase this on top of that PR it seems to work on wasm though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have a few small suggestions, but they're non-blocking. The one thing I was not able to test was closing a window to exit the app. For some reason it is freezing on my laptop. (It's on main too, though, not just you.)
Edit: It's freezing because of #13208, so don't worry about it. If someone else to test closing a window to exit an app, that would be great! :)
2bfe288
to
851b21a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My PR here #13236 chose to just use event_loop.exiting()
which I think is simpler. I agree with the outstanding question about whether it makes sense to process events after exit has been signaled or not. If it is indeed true that we guarantee nothing happens after exit has been called, it makes sense to swallow additional incoming events. However, I don't understand all the ceremony around exit_happened
and processing the LoopExiting
event. Personally, i'd just wrap the entire handler in if !event_loop.exiting()
.
crates/bevy_winit/src/lib.rs
Outdated
@@ -772,13 +788,28 @@ fn handle_winit_event( | |||
Event::UserEvent(RequestRedraw) => { | |||
runner_state.redraw_requested = true; | |||
} | |||
Event::LoopExiting => { | |||
let exit = exit_happened.clone().unwrap_or_else(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unreachable. We only receive this event if we call event_loop.exit()
, which is guaranteed to have set *exit_happened = Some(app_exit)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event drop code specifically let's through the LoopExiting
event.
bevy/crates/bevy_winit/src/lib.rs
Lines 364 to 367 in 851b21a
if exit_happened.is_some() && event != Event::LoopExiting { | |
debug!("App is exiting. Dropping event: {event:?}"); | |
return; | |
} |
I didn't put much thought into my solution as I know this code will get replaced soonTM. I'd modify your solution to drop events after we start exiting the event loop and merge it instead of this one. That's not my call to make though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just saying we'll only receive LoopExiting
if we've already called event_loop.exit()
which in the control flow here guarantees exit_happened
is Some
. Agree that this code will likely change a lot post non-send changes.
Closed in favor of #13236. |
Objective
As was notice on discord. Running an app currently output
ERROR bevy_winit: Failed to send a app exit notification! This is a bug. Reason: sending on a full channel
. This happens because after triggering a event loop exit we still receive queued events. This triggers the event loop exit code again causing the warning. If one of the events we receive isAboutToWait
we also update the app which goes against the promise made in theAppExit
documentation.Solution
exit_happened
flag that gets set when we trigger a app exit.LoopExiting
event.LoopExiting
event send theAppExit
that triggered the exit to the winit_runner.Testing
No windows are open, exiting
message and no errors.If somebody could test this code on wasm I'd really appreciate it. Every time I try to do it I get a
GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
error, so I can't test it myself.