Description
After maybe 30 minutes or an hour, pretty much randomly it seems, my event loop freezes on Windows only. I created a very simple demo application which triggers the problem: https://github.com/ebfull/brokensdl
extern crate sdl2_window;
extern crate opengl_graphics;
extern crate piston;
use std::cell::RefCell;
use sdl2_window::Sdl2Window;
pub use opengl_graphics::{ Gl, OpenGL };
use piston::window::WindowSettings;
use piston::event::{
self,
Event
};
pub use piston::event::{
RenderArgs,
UpdateArgs
};
fn main() {
let opengl = OpenGL::_3_2;
let window = RefCell::new(Sdl2Window::new(
opengl,
WindowSettings {
title: format!("Howdy!"),
size: [900, 900],
fullscreen: false,
exit_on_esc: true,
samples: 4,
}
));
let mut gl = Gl::new(opengl);
for event in event::events(&window) {
println!("processing event: {:?}", event);
if let Event::Render(args) = event {
gl.draw([0, 0, args.width as i32, args.height as i32], |_, gl| {});
}
println!("finished event!");
}
}
As you can see in my program, I print at the beginning and end of the event loop iteration to demonstrate the event loop is getting stuck on the iterator's .next().
Here's the console output of my program:
finished event!
processing event: Update(UpdateArgs { dt: 0.008333 })
finished event!
processing event: Idle(IdleArgs { dt: 0.002937 })
finished event!
processing event: Update(UpdateArgs { dt: 0.008333 })
finished event!
processing event: Update(UpdateArgs { dt: 0.008333 })
finished event!
processing event: Idle(IdleArgs { dt: 0.000382 })
finished event!
processing event: Idle(IdleArgs { dt: 5153.363529 })
finished event!
processing event: Idle(IdleArgs { dt: 0.004295 })
finished event!
processing event: Idle(IdleArgs { dt: 5153.365719 })
finished event!
processing event: Idle(IdleArgs { dt: 5153.367442 })
finished event!
processing event: Idle(IdleArgs { dt: 5153.337568 })
finished event!
Suddenly it seems, IdleArgs starts sending me a dt of over 5000. The window becomes unresponsive. Fetching the "next" event takes forever.
I looked at the stack of the only thread doing anything:
ntoskrnl.exe!memset+0x61a
ntoskrnl.exe!KeWaitForMultipleObjects+0xd52
ntoskrnl.exe!KeWaitForSingleObject+0x19f
ntoskrnl.exe!_misaligned_access+0xba4
ntoskrnl.exe!_misaligned_access+0x1821
ntoskrnl.exe!KeWaitForMultipleObjects+0xf5d
ntoskrnl.exe!KeWaitForSingleObject+0x19f
ntoskrnl.exe!NtWaitForSingleObject+0xde
ntoskrnl.exe!KeSynchronizeExecution+0x3a23
ntdll.dll!NtWaitForSingleObject+0xa
KERNELBASE.dll!WaitForSingleObjectEx+0x9c
SDL2.dll!SDL_LogCritical+0xad1d6
SDL2.dll!SDL_LogCritical+0xad8c5
SDL2.dll!SDL_LogCritical+0xa8339
SDL2.dll!SDL_LogCritical+0x49ae7
SDL2.dll!SDL_LogCritical+0xad3ca
kernel32.dll!BaseThreadInitThunk+0xd
ntdll.dll!RtlUserThreadStart+0x21
It's pretty much stuck calling SDL_LogCritical over and over? Or maybe SDL_LogCritical is getting stuck? I've tried several times to get errors out of SDL but I have no idea how. Is there any way to debug this further? I can replicate the issue very consistently, just keep the application open.