From e75f6171255c42079decd96e4f581edcb7e0903c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 9 Dec 2020 17:25:49 +0100 Subject: [PATCH] Fix event loop being blocked because it wouldn't notice that animation is still running The active_animation was set to false, but if the animation tick did not change, the animation tick was not maked dirty, and we wouldn't then re-evaluate animated property that would set the active_animation to true again --- sixtyfps_runtime/corelib/animations.rs | 6 ++++-- sixtyfps_runtime/corelib/eventloop.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sixtyfps_runtime/corelib/animations.rs b/sixtyfps_runtime/corelib/animations.rs index fe4cebc75..fa2cb72ff 100644 --- a/sixtyfps_runtime/corelib/animations.rs +++ b/sixtyfps_runtime/corelib/animations.rs @@ -98,8 +98,10 @@ impl AnimationDriver { /// Iterates through all animations based on the new time tick and updates their state. This should be called by /// the windowing system driver for every frame. pub fn update_animations(&self, new_tick: Instant) { - self.active_animations.set(false); - self.global_instant.as_ref().set(new_tick); + if self.global_instant.as_ref().get() != new_tick { + self.active_animations.set(false); + self.global_instant.as_ref().set(new_tick); + } } /// Returns true if there are any active or ready animations. This is used by the windowing system to determine diff --git a/sixtyfps_runtime/corelib/eventloop.rs b/sixtyfps_runtime/corelib/eventloop.rs index 23bb3df0d..012c30bf0 100644 --- a/sixtyfps_runtime/corelib/eventloop.rs +++ b/sixtyfps_runtime/corelib/eventloop.rs @@ -214,6 +214,7 @@ pub(crate) fn unregister_window(id: winit::window::WindowId) { /// This enum captures run-time specific events that can be dispatched to the event loop in /// addition to the winit events. +#[derive(Debug)] pub enum CustomEvent { /// Request for the event loop to wake up and poll. This is used on the web for example to /// request an animation frame. @@ -476,7 +477,6 @@ impl EventLoop { return; } *control_flow = ControlFlow::Poll; - //println!("Scheduling a redraw due to active animations"); ALL_WINDOWS.with(|windows| { windows.borrow().values().for_each(|window| { if let Some(window) = window.upgrade() {