-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add option to ignore events when receving unknown WindowId #1072
Conversation
3557127
to
1d3be38
Compare
When can Bevy receive window event for an unknown window id? |
I've seen it happen in two situations. First, when running multiple bevy app simultaneously. I don't think this is something that bevy need to support. Second, when running two bevy app one after the other with I'm personally running in the second case when running bevy app as integration tests sequentially. One alternative to this PR would be to drain the event loop before or after running a bevy app. However, I don't really know how to do that. |
If it can happen during normal run, we should make it default behavior (maybe with logging a warning), not an option. |
I don't have an strong opinion for setting it as default behavior or an option. I'll change the PR accordingly if needed. Who would decide on this? Should I open 2 PR and we vote on them? |
Ultimately @cart has a last word. |
@refnil I looked a little into that as I had a somewhat similar issue with event happening for a closed window. you can check #1082 (second crash) for some details. Just noticed you actually talking about that there Could you list the events that you receive after in your case? Is it just a |
@mockersf I think I only received Focused events. Didn't really check for more detail at the time. I don't know if it is possible to receive other events unless you are running multiple winit app at the same time. In that case, events seem to be distributed randomly between the multiple event loops. I'll follow up in your PR since I have some thought about it. |
In that case, I think the two cases (Focused for one loop after another, and random events between multiple loops) should be handled differently... how does it even work if events are random between the loops? |
For the multiple loops thing, I don't think we should handle that a all. I could be wrong but I think there could be something in the windowing stack |
(copying in some notes on this pr from #1082)
|
No problem. I'll rebase soon. |
1d3be38
to
61ed1a3
Compare
I've removed the option and reverted the WindowEvent::Focused part of #1082. Let me know if there is anything else to do. |
just made a couple of minor tweaks. lets get this merged! |
Bevy would panic when received window event for an unknown window id. This pull request add the option
ignore_unknown_window_id
to WinitConfig. When false, we keep the current behavior (panicking on unknown ID) which I think is fine for most regular bevy app. When true, a guard is added in the event loop and exit early if an unknown id is received.This new behavior is useful when testing bevy app (see #1057).