Fix constant wakeups with the winit event loop

Commit 2b7a1eebcd introduced a deep clone of the winit event loop proxy inside the event run function callback.
That introduced constant wakeups because cloning an event loop
proxy creates a new one, which adds a source to the cf run loop and also
explicitly triggers a wakeup.

Fortunately we don't really need that clone, a reference works just fine and is faster.
This commit is contained in:
Simon Hausmann 2021-04-08 09:35:07 +02:00
parent 161a35ef5c
commit 9726df9c00

View file

@ -39,7 +39,7 @@ impl NotRunningEventLoop {
struct RunningEventLoop<'a> { struct RunningEventLoop<'a> {
event_loop_target: &'a winit::event_loop::EventLoopWindowTarget<CustomEvent>, event_loop_target: &'a winit::event_loop::EventLoopWindowTarget<CustomEvent>,
event_loop_proxy: winit::event_loop::EventLoopProxy<CustomEvent>, event_loop_proxy: &'a winit::event_loop::EventLoopProxy<CustomEvent>,
} }
pub(crate) trait EventLoopInterface { pub(crate) trait EventLoopInterface {
@ -186,7 +186,7 @@ pub fn run(quit_behavior: sixtyfps_corelib::backend::EventLoopQuitBehavior) {
event_loop_target: &EventLoopWindowTarget<CustomEvent>, event_loop_target: &EventLoopWindowTarget<CustomEvent>,
control_flow: &mut ControlFlow| { control_flow: &mut ControlFlow| {
let running_instance = let running_instance =
RunningEventLoop { event_loop_target, event_loop_proxy: event_loop_proxy.clone() }; RunningEventLoop { event_loop_target, event_loop_proxy: &event_loop_proxy };
CURRENT_WINDOW_TARGET.set(&running_instance, || { CURRENT_WINDOW_TARGET.set(&running_instance, || {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;