Timer appears to be broken in headless setups
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
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 }
```
```rust
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::
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 to `update`.
- 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.
Contributor guide
Research direction
Start with the minimal reproduction in Cargo.toml and src/main.rs, running it against Bevy v0.16.0 and v0.15.3 to confirm the difference. Trace the update path from app.update() to Time.delta_secs(); done means headless manual updates report the elapsed interval rather than roughly twice it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100