Open
Description
Bevy version
v0.16.0
What you did
Using a headless setup with manual updates, when upgrading from v0.15 to v0.16, Time.delta_secs()
is reporting durations which are ~2x the actual elapsed time between calls to update
. This was originally observed in a Godot project using bevy via gdext, but it can be reproduced with a minimal project:
Cargo.toml:
[package]
name = "slow_timer"
version = "0.1.0"
edition = "2024"
[dependencies]
bevy = { version = "0.16.0", default-features = false }
use std::time::Duration;
use bevy::prelude::*;
fn main() {
let mut app = App::new();
app.add_plugins(MinimalPlugins).finish();
loop {
app.update();
let time = app.world().resource::<Time>();
dbg!(time.delta_secs());
std::thread::sleep(Duration::from_secs_f32(0.01));
}
}
Which logs:
...
[src/main.rs:12:9] time.delta_secs() = 0.025558336
[src/main.rs:12:9] time.delta_secs() = 0.02548195
[src/main.rs:12:9] time.delta_secs() = 0.025628762
[src/main.rs:12:9] time.delta_secs() = 0.025477076
[src/main.rs:12:9] time.delta_secs() = 0.025474293
[src/main.rs:12:9] time.delta_secs() = 0.0254678
[src/main.rs:12:9] time.delta_secs() = 0.025397876
[src/main.rs:12:9] time.delta_secs() = 0.025550036
Note that if I downgrade this minimal example to v0.15.3, I get the correct expected output:
...
[src/main.rs:12:9] time.delta_secs() = 0.010308759
[src/main.rs:12:9] time.delta_secs() = 0.010201677
[src/main.rs:12:9] time.delta_secs() = 0.010415471
[src/main.rs:12:9] time.delta_secs() = 0.010514128
[src/main.rs:12:9] time.delta_secs() = 0.010201179
[src/main.rs:12:9] time.delta_secs() = 0.010178561
[src/main.rs:12:9] time.delta_secs() = 0.010178767
What went wrong
- Expecting:
time.delta_secs()
to represent the actual time elapsed between calls toupdate
. - Actual results: values that are roughly 2x the actual elapsed time.
Additional information
I was trying to look through the changes to spot what could have possibly changed since v0.15, and the only thing I can spot is that there seems to have been some changes to support no_std, but it's not clear to me what within that could be causing it, if anything.