Repository navigation
Animato v1.7.4 — Dioxus Desktop Animation Loop Fix
Animato v1.7.4 is a focused patch release that fixes
#57: on dioxus-desktop
every animato-dioxus hook (use_tween, use_spring, use_timeline,
use_keyframes, plus use_motion and use_drag) froze the window. The
native animation loop called std::thread::sleep inside an async block
without ever awaiting, so the future never yielded and blocked the Dioxus
executor and UI thread — the window opened, then showed "Not Responding"
with near-zero CPU because the thread was sleeping, not spinning.
Highlights
- Non-blocking frame pacing. The native loop now awaits
futures_timer::Delay(~16 ms) between frames instead of
std::thread::sleep. The dioxus 0.7.9 source shows dioxus-desktop polls
the VirtualDom with a plain tao waker outside any tokio runtime
(webview.rs::poll_vdom), so atokio::time::sleeptimer would have
panicked at runtime;futures-timeris runtime-agnostic and works under
any executor. The dependency is native-target-only — wasm32 keeps the
requestAnimationFrame loop and gains no new dependencies. - Loops park when idle. Each hook previously returned
true
unconditionally from its loop closure, so completed tweens and settled
springs re-rendered ~60×/s forever (Signal::setalways notifies
subscribers). Finished and paused engines now park the loop and zero
frames are scheduled until the animation is reactivated. - One engine per component.
use_tween,use_spring,use_timeline,
use_keyframes,use_motion, anduse_dragcreate the engine and
control handle once insideuse_hook. Previously every render built a
fresh engine plusArc<Mutex<…>>while only the first render's loop was
running;play(),seek(), andset_target()calls from later renders
silently drove an engine nothing was animating. - Handle methods wake parked loops:
play(),resume(),reset(),
seek(),reverse(),set_target(),animate_to(),spring_to(),
keyframes(), and drag release inertia. The web rAF loop parks the same
way via a resumption thunk. - New:
TweenHandle::is_playing()andTimelineHandle::is_playing(). - No public API was removed or renamed; std-mode users are unaffected
apart from the intended re-render fix.
Reproduction from #57
use animato::dioxus::use_tween;
use animato::Easing;
use dioxus::prelude::*;
#[component]
fn App() -> Element {
let (x, _h) = use_tween(0.0_f32, 100.0, |b| b.duration(1.0).easing(Easing::EaseOutCubic));
rsx! { div { "x = {x():.1}" } }
}Before v1.7.4 the window stopped responding after mount. After v1.7.4 the
value counts 0→100, the window stays interactive, and re-renders stop once
the tween completes.
Building
[dependencies]
animato = { version = "1.7.4", features = ["dioxus-desktop"] }
dioxus = { version = "0.7.9", default-features = false, features = ["desktop", "launch"] }All workspace crates are versioned together at 1.7.4 in this release.
What's Changed
- fix(dioxus): stop animation loop blocking the UI thread on desktop (#57) by @aarambh-darshan in #58
Full Changelog: v1.7.3...v1.7.4