bevyengine / bevyengine/bevy

Frame rate permanently drops overtime

Open
#11,285 17 comments 3 reactions 0 assignees View on GitHub
C-Performance S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.12.1

## \[Optional\] Relevant system information

- Windows 10
- cargo 1.76.0-nightly (2c03e0e2d 2023-11-16)
- tested on two machines : i5, 16gb mem, gtx 970 and i5, 8gb mem, gtx 670

## What you did

Created a test program displaying the framerate, and left it running for 8+ hours.

## What went wrong

Was expecting framerate to stay at 60 fps. But framerate would decrease over time, down to about 15fps and never recover.

## Additional information

Framerate decreases faster when:

* more going on (eg lots of entities/components, rendering)
* when running another program that has high cpu/gpu usage at the same time as the bevy app

With a barebones bevy app, it can take up to a day or possibly longer for the framerate to decrease.

In my bevy app, the menus are noticeably laggy to interact with after the framerate has dropped to 50-45 fps.

### Test code

`Cargo.toml` :

```toml
[package]
name = "hello"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.12.1"
```

`rust-toolchain.toml` :

```toml
[toolchain]
channel = "nightly"
```

`main.rs` :

```rust

use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, DiagnosticsStore};
use bevy::prelude::*;

fn main() {
let mut app = App::new();

app
.add_plugins(( bevy::prelude::DefaultPlugins, FrameTimeDiagnosticsPlugin::default(), ))
.add_systems(Update, ( show_fps_in_title, )) ;

app.run();
}

fn show_fps_in_title( mut windows: Query<&mut Window>, diagnostics: Res, ) {
let Ok(mut window) = windows.get_single_mut() else { return; };

let (fps,avg,smoothed) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS)
.map(|x|(x.value().unwrap_or_default(),x.average().unwrap_or_default(),x.smoothed().unwrap_or_default()))
.unwrap_or_default();

window.title = format!("{fps:.0} {avg:.0} {smoothed:.0}");
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.