Skip to content
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

Intermittent hangs on Windows when using ControlFlow::Poll #1522

Closed
ThatsNoMoon opened this issue Apr 5, 2020 · 3 comments
Closed

Intermittent hangs on Windows when using ControlFlow::Poll #1522

ThatsNoMoon opened this issue Apr 5, 2020 · 3 comments
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - windows

Comments

@ThatsNoMoon
Copy link

ThatsNoMoon commented Apr 5, 2020

Running a minor adaptation of the window example using ControlFlow::Poll leads to intermittent hangs on Windows (10.0.18362), wherein winit dispatches NewEvents(Poll), MainEventsCleared, and RedrawEventsCleared continuously, causing Windows to treat the window as not responding, until winit dispatches a Resized WindowEvent with the same size as the window had before.

use winit::{
    event::{Event, WindowEvent},
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

fn main() {
    simple_logger::init().unwrap();
    let event_loop = EventLoop::new();

    let window = WindowBuilder::new()
        .build(&event_loop)
        .unwrap();

    event_loop.run(move |event, _, control_flow| {
        *control_flow = ControlFlow::Poll;
        log::debug!("event: {:?}", event);

        match event {
            Event::WindowEvent {
                event: WindowEvent::CloseRequested,
                window_id,
            } if window_id == window.id() => *control_flow = ControlFlow::Exit,
            Event::WindowEvent {
                event: WindowEvent::Resized(size),
                ..
            } => log::warn!("Resized to {:?}", size),
            Event::MainEventsCleared => {
                window.request_redraw();
            }
            _ => (),
        }
    });
}

Here's the section of the log output around where the hang stopped:

2020-04-04 21:03:06,610 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,610 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,611 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,611 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,611 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,611 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,611 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,615 DEBUG [window] event: WindowEvent { window_id: WindowId(WindowId(0x170a68)), event: Resized(PhysicalSize { width: 1024, height: 768 }) }
2020-04-04 21:03:06,615 WARN  [window] Resized to PhysicalSize { width: 1024, height: 768 }
2020-04-04 21:03:06,619 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,619 DEBUG [window] event: RedrawRequested(WindowId(WindowId(0x170a68)))
2020-04-04 21:03:06,620 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,620 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,620 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,620 DEBUG [window] event: RedrawRequested(WindowId(WindowId(0x170a68)))
2020-04-04 21:03:06,621 DEBUG [window] event: RedrawEventsCleared

Little information to be gained from the log from when the hang started:

2020-04-04 21:03:06,210 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,210 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,211 DEBUG [window] event: RedrawRequested(WindowId(WindowId(0x170a68)))
2020-04-04 21:03:06,211 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,212 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,212 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,213 DEBUG [window] event: RedrawRequested(WindowId(WindowId(0x170a68)))
2020-04-04 21:03:06,215 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,215 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,215 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,218 DEBUG [window] event: RedrawEventsCleared
2020-04-04 21:03:06,219 DEBUG [window] event: NewEvents(Poll)
2020-04-04 21:03:06,219 DEBUG [window] event: MainEventsCleared
2020-04-04 21:03:06,220 DEBUG [window] event: RedrawEventsCleared

winit also doesn't appear to dispatch any other events, like keyboard or mouse events, while it's in this "loop".

@ryanisaacg ryanisaacg added DS - windows C - needs investigation Issue must be confirmed and researched B - bug Dang, that shouldn't have happened labels Apr 6, 2020
@filnet
Copy link
Contributor

filnet commented Apr 9, 2020

Seems related to #1477

@0x08088405
Copy link

0x08088405 commented Apr 13, 2020

Getting this as well on Windows 10 Version 1809 (build 17763.1098) 😢
Worst part is, sometimes it just doesn't do it so I think the bug went away, but then it becomes frequent again so it's hard to tell whether it's present at all.
Edit: Tested, looks like #1496 fixes this... not merged, though.

@Osspial
Copy link
Contributor

Osspial commented Apr 19, 2020

I'm closing this as a duplicate of #1477. Still, thanks for reporting it!

@Osspial Osspial closed this as completed Apr 19, 2020
ThatsNoMoon added a commit to ThatsNoMoon/evalvana that referenced this issue Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - windows
Development

No branches or pull requests

5 participants