Skip to content

Fix panic in FpsOverlay with disabled FrameTimeGraph #20461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nekonimous
Copy link
Contributor

Objective

I am getting the following panic on start:

thread 'main' panicked at /home/User/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wgpu-26.0.1/src/backend/wgpu_core.rs:1195:26:
wgpu error: Validation Error

Caused by:
  In Device::create_bind_group, label = 'FrametimeGraphMaterial'
    Buffer with '' label binding size is zero


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::render_asset::prepare_assets<bevy_ui_render::ui_material_pipeline::PreparedUiMaterial<bevy_dev_tools::frame_time_graph::FrametimeGraphMaterial>>`!

when registering the FpsOverlayPlugin with the frame time graph disabled by default:

app.add_plugins(FpsOverlayPlugin {
    config: FpsOverlayConfig {
        text_config: TextFont {
            font_size: 18.0,
            ..Default::default()
        },
        frame_time_graph_config: FrameTimeGraphConfig {
            enabled: false, // causes panic above
            ..Default::default()
        },
        enabled: false,
        ..Default::default()
    },
})

Solution

I went with the most pragmatic fix I could find, since I am no render/shader expert but I can imagine there is a better way to fix this, please let me know. My reasoning being:

It does not panic after update_frame_time_values called buffer.set_data(frame_times.clone().as_slice()). So I ended up logging the buffer inside the system, and the first time it is called with empty frame_times it writes it into the ShaderStorageBuffer as [0, 0, 0, 0]. Doing the same when initializing the storage buffer fixes the panic on start.

@alice-i-cecile alice-i-cecile added P-Crash A sudden unexpected crash A-Dev-Tools Tools used to debug Bevy applications. D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Aug 9, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about why this is needed please so we don't "clean this up". This also seems like a prime opportunity for a constructor on ShaderStorageBuffer for these sorts of patterns, but I won't block on that.

@nekonimous
Copy link
Contributor Author

@alice-i-cecile I added a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dev-Tools Tools used to debug Bevy applications. D-Straightforward Simple bug fixes and API improvements, docs, test and examples P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants