Function bevy_framepace::framerate_limiter
source · pub fn framerate_limiter(
timer: ResMut<'_, FrameTimer>,
target_frametime: Res<'_, FrametimeLimit>,
stats: Res<'_, FramePaceStats>
)
Expand description
Accurately sleeps until it’s time to start the next frame.
The spin_sleep
dependency makes it possible to get extremely accurate sleep times across
platforms. Using std::thread::sleep()
will not be precise enough, especially windows. Using a
spin lock, even with std::hint::spin_loop()
, will result in significant power usage.
spin_sleep
sleeps as long as possible given the platform’s sleep accuracy, and spins for the
remainder. The dependency is however not WASM compatible, which is fine, because frame limiting
should not be used in a browser; this would compete with the browser’s frame limiter.