-
Notifications
You must be signed in to change notification settings - Fork 928
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 several crashes on Windows by heavily simplifying the event loop code #1496
Conversation
Did some testing with the When using
Issues:
|
When using
And with this fix only a single |
When using
|
@Osspial may be we should first merge my PR and then you could try your new approach on top of it. My PR addresses the same issues as yours but is 100% in line with the current code/approach. No revolution there. If we do that then we get a more stable version of winit on Windows out now and you can then work on the new approach without pressure. PS: my PR still needs to be reviewed though ;) |
That sounds like a good approach. I'll try to get your PR, and a bunch of the other Windows PRs that have been waiting on the backburner, reviewed later today. |
@filnet Would you be able to re-test this? I'm pretty sure I've fixed the bugs you brought up in your comments. |
Retested the same use cases and it looks fine. |
More testing shows that there might still be an issue with WaitUntil control flow. I am seeing this in my project. I can't reproduce it with the control_flow example. |
Changing the wait time in control_flow from 100ms to (1000 / 60)ms reproduces the issue. You need to switch to WaitUntil control flow (by pressing '2'). Then move the mouse out of the window and back in. You should see that you then only get WindowEvent or DeviceEvent. Resizing the window will either restore the event loop to a working state or emit a LoopDestroyed event (!?!). Edit: you get the LoopDestroyed event if you try to close the window in the broken state and then resize. |
I'll admit that the secondary thread introduces a bit more complexity to the implementation, but there are a couple technical reasons that justify its inclusion:
That's... certainly bizarre! It'll take a bit to figure out why exactly that happens, since this doesn't seem like a bug with a simple, obvious fix. |
Alright, I fixed it! It was caused by a bug in |
It is not a bug in
|
I'll do a more in depth review this week (with an eye for pre 0.20.0 multithreaded left overs). One thing I'd like to confirm is if we can get rid of the @Osspial would be great if you could rebase your branch against master. |
Found an issue: in WaitUntil control flow the event loop will not start until a first event happens. |
About the We first need to merge this pull request : #1511 Then you need to change the example to start in
With those changes, the event loop does not start. Seems like WaitUntil with an expired time is not well handled. |
Any update on this? I was planning on using |
Seconding this, looks like the fix was implemented a month ago but never merged? Were there some unforeseen side effects of this fix? Can help out too if possible. Edit: Tested the branch, confirming that it does fix the issue 👍 |
Will test that branch this weekend. |
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.
Could you please add some doco to the run_return method.
This guy is the workhorse of this file it would just be great to have some high level stuff especially for the non windows dev folks like me, unless I go to the Windows API I cant tell what this is doing.
(Of course I did go to the windows API and its very useful)
Things like
- GetMessageW blocks until a message is received and it returns -1,0,1
- Why are we Translating/Dispatching messages?
- What does runner.poll() do
The docs on flush_paint_messages are amazing.
I liked how explicit the control flow was before, now you have to dig a little deeper to find it.
It's fine, I just would like to know everything by reading this one method.
Quickly tested all control flow modes with and without calling |
…nt loop code (rust-windowing#1496)" This reverts commit b4c6cdf.
…nt loop code (rust-windowing#1496)" This reverts commit b4c6cdf.
…nt loop code (rust-windowing#1496)" This reverts commit b4c6cdf.
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to usersI'll do a more detailed writeup on the rationale behind these changes when I'm more awake, but the TL;DR is that it drastically simplifies Winit's event loop model by always using the modal event loop. This PR's fixes are an alternate approach to the problems described in #1429 that simplifies the event model more than #1461 does, but it could not exist in its current form without @filnet's work and feedback in those threads.
Fixes #1477, fixes #1496.