-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix example return_after_run #1082
Fix example return_after_run #1082
Conversation
I had the same errors while doing integration tests (#1057). I've had not submitted a PR for the subscriber thing yet because I used the workaround of not including the I don't think silently ignoring the subscriber errors is a good idea long term. We could still merge this but open an issue to make it better later. I think a have three options.
I hope that some of that make sense. Next, let talk about the window id issues. I see that you fixed it only for the |
You're right about logs, I changed the PR:
|
That looks good to me for the subscriber thing. I didn't know about |
This looks good to me. @refnil I prefer "one way that works by default" instead of giving people too many choices. I'm going to merge this because 0.4 is dropping soon. But I do like the approach in your PR to factor out the winit window fetch. It cuts down on duplicate boilerplate and ensures we ignore events the same way everywhere. If you can rebase your changes on master (after I merge this pr) and then remove the configuration option, I'd love to merge those changes (although i won't block the 0.4 release on it). |
First crash
Example return_after_run is currently crashing when closing the first window:
The issue is that as the default plugins setup a global tracing subscriber, doing it a second time fails. https://docs.rs/tracing/0.1.22/tracing/dispatcher/fn.set_global_default.html for more information
My fix is to ignore errors, as it just means that there is already a subscriber configured.
As an added bonus, the user can now set up their own subscriber however they want.
Second crash
The example was still crashing:
After some investigation, it's because the event loop for the second app receives an event
Focused(false)
from the window of the first app. It can be reproduced when using only winit, and looking at how it works it may be platform dependant (I'm on macOS) and events are just translated from the OS, so not something fixable.My fix is to ignore
Focused(false)
events for unknown window, as they are pretty much meaningless anyway. I kept the crash for aFocused(true)
event on an unknown window.It runs!
Now it works :)