Skip to content

fix: properly sleep between animation frames#328

Open
yuukidach wants to merge 1 commit into
acsandmann:mainfrom
yuukidach:fix/animation-sleep
Open

fix: properly sleep between animation frames#328
yuukidach wants to merge 1 commit into
acsandmann:mainfrom
yuukidach:fix/animation-sleep

Conversation

@yuukidach
Copy link
Copy Markdown
Contributor

@yuukidach yuukidach commented Mar 31, 2026

Summary

  • Timer::sleep(duration) in Animation::run() creates a Future but never .awaits it, so it's immediately dropped — animation frames execute in a tight loop with no delay
  • Replaced with std::thread::sleep(duration) since run() is a synchronous function, properly pacing frames at the configured FPS (default 100fps over 300ms)

Timer::sleep(duration) creates a Future but was never awaited,
causing animation frames to execute in a tight loop with no delay.
Use std::thread::sleep instead since Animation::run() is synchronous.
@yuukidach yuukidach force-pushed the fix/animation-sleep branch from c662abb to bb8a581 Compare March 31, 2026 07:01
@Swoorup
Copy link
Copy Markdown
Contributor

Swoorup commented Apr 9, 2026

Wonder if something like this would also help to interpolate animation more smoothly or is it overkill? (Bevy uses this)
https://docs.rs/spin_sleep/latest/spin_sleep/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants