-
Notifications
You must be signed in to change notification settings - Fork 948
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
EventsLoopProxy::wakeup does not fire until mouse is moved over window (Windows) #550
Comments
I would've appreciated a heads up that this requires nightly, since things compile pretty slowly on my laptop. Maybe you could add a Anyway, I can reproduce this on Windows 10. Do you only have this issue with trying to awaken after resizing, or is it with any event? |
If you run this: extern crate winit;
use std::sync::{Arc, Mutex};
fn main() {
let mut events_loop = winit::EventsLoop::new();
let _window = winit::WindowBuilder::new()
.with_title("A fantastic window!")
.build(&events_loop)
.unwrap();
let proxy = events_loop.create_proxy();
let count = Arc::new(Mutex::new(0usize));
{
let count = Arc::clone(&count);
std::thread::spawn(move || {
// Wake up the `events_loop` once every second.
loop {
std::thread::sleep(std::time::Duration::from_secs(1));
proxy.wakeup().unwrap();
*count.lock().unwrap() += 1;
}
});
}
events_loop.run_forever(|event| {
match event {
winit::Event::Awakened => {
println!("WAKE UP {}", count.lock().unwrap());
winit::ControlFlow::Continue
}
winit::Event::WindowEvent { event: winit::WindowEvent::CloseRequested, .. } =>
winit::ControlFlow::Break,
_ => winit::ControlFlow::Continue,
}
});
} You'll see that any wakeup messages sent during a resize are eaten. If your issue is specific to resizing (which has special handling), then it seems quite likely to be related to this. |
It shouldn't require nightly... rustc 1.26 stable works for me, which is also what I'm using for CI. What problems did you have with that? Maybe you had an older compiler installed (1.26 is rather recent)? Your example works for me, too - the timer is incremented, but the wakeup event is ignored. This example confirms the bug, no? I do not know if other events "eat" the wakeup events, too. For now, if it would just work properly during resize events, that'd be great. That would explain why the screen doesn't even update after the resize is finished - the wakeup event gets eaten, and the events loop never knows that the next frame is ready and it should just swap the buffers. But I'm curious why the events loop is different for resizing vs custom events. Isn't it just one big queue that both the resize event (called by Windows) and the |
Ah, that's surely the case; I only use my Windows machine for working on winit, so I never really update. Sorry.
So you remember #506? Well, just like that, this comes down to the same problem that #445 exists to solve. Due to how Windows works, resizing the window blocks the event processing thread (which is why we have it on a separate thread in the first place). The details are outlined more in #459. Seeing as that complexity has foiled you twice now, I'll give you another update on the resolution timeline.
So, with all of that, this could probably be fixed by July 4th! Alternatively, I could stick a |
Yeah, don't overwork yourself. Thanks for taking a look in the first place. I don't think a hotfix is that necessary right now, if it get's removed anyway, so I'd rather wait for the proper solution. Regarding #506, I've thought about this and come to the conclusion, that Windows doesn't really leave me any other choice other than drawing my own menus (in seperate windows) - because as soon as I use a different thread, it locks up the whole app. It's not that hard when I have text rendering, etc. working. It's just that the Win32 API was written for a different century, it seems. |
Any news on this? Just asking. |
I think it became "in flux" again in July after #459 (comment), after which several questions / alternative proposals came in. Edit (reading through it again took some time |
Ah right, but Now we seem to be getting close to something. I think @Osspial is doing a great job of summarizing the thread. |
Does #634 help with this? |
The problem is this: I have a
Window
, which stores theEventsLoop
. Now, webrender, which I use for drawing, is async in nature, so if I say "render a frame", I don't know when the frame is going to be finished. For this, webrender has aRenderNotifier
trait, which I can implement to callEventsLoopProxy::wakeup()
.The
wakeup()
is called correctly, but I don't get an "awakened" event until the mouse is moved over the window. ButEvent::Awakened
is not a window event, it doesn't have anything to do with the window. This is especially noticable when resizing windows:The code where I am trying this is here:
RenderNotifier: https://github.com/maps4print/azul/blob/402f21d72e012530f07156044def701d79043321/src/window.rs#L318-L334
Submitting new frames: https://github.com/maps4print/azul/blob/402f21d72e012530f07156044def701d79043321/src/app.rs#L567-L568
Polling: https://github.com/maps4print/azul/blob/402f21d72e012530f07156044def701d79043321/src/app.rs#L159-L164
Handling the awakened event: https://github.com/maps4print/azul/blob/402f21d72e012530f07156044def701d79043321/src/app.rs#L517-L520
I poll indefinitely (but not using
run_forever()
, because reasons). In theory it should always print:However, all I get is the first two messages, only if I move the mouse over the window, then it updates the screen. If the mouse is over the window, but doesn't move, it doesn't send the Awakened event either. You can clone the repository and run
cargo run --example debug
to replicate this.Initial state:
After resizing:
After moving the mouse over the window:
The problem is that while I could swap the buffers at 60FPS, this blocks until the backbuffer is finished, so I'd be waiting on webrender to finish, which blocks events to be processed immediately and leads to lagging when resizing the window, so I'd rather not do that. I'm currently experiencing this on Windows 8, I'm not sure if this also happens on other windowing systems.
The text was updated successfully, but these errors were encountered: