Repository: bevyengine/bevy
File: crates/bevy_dev_tools/src/fps_overlay.rs (Rust)

Code before:
    mut frame_time_graph_materials: ResMut<Assets<FrametimeGraphMaterial>>,
    mut buffers: ResMut<Assets<ShaderStorageBuffer>>,
) {
    commands
        .spawn((
            Node {
                // We need to make sure the overlay doesn't affect the position of other UI nodes
                position_type: PositionType::Absolute,
                flex_direction: FlexDirection::Column,
                ..Default::default()
            },
            // Render overlay on top of everything
            GlobalZIndex(FPS_OVERLAY_ZINDEX),
            Pickable::IGNORE,
        ))
        .with_children(|p| {
            p.spawn((
                Text::new("FPS: "),
                overlay_config.text_config.clone(),
                TextColor(overlay_config.text_color),
                FpsText,
                Pickable::IGNORE,
            ))
            .with_child((TextSpan::default(), overlay_config.text_config.clone()));

            #[cfg(target_arch = "wasm32")]
            {
                if overlay_config.frame_time_graph_config.enabled {
                    use tracing::warn;

                    warn!("Frame time graph is not supported on wasm32 targets.");
                }
            }
            #[cfg(not(target_arch = "wasm32"))]
            {
                let font_size = overlay_config.text_config.font_size;
                p.spawn((
                    Node {
                        width: Val::Px(font_size * FRAME_TIME_GRAPH_WIDTH_SCALE),
                        height: Val::Px(font_size * FRAME_TIME_GRAPH_HEIGHT_SCALE),
                        display: if overlay_config.frame_time_graph_config.enabled {
                            bevy_ui::Display::DEFAULT
                        } else {
                            bevy_ui::Display::None
                        },
                        ..Default::default()
                    },
                    Pickable::IGNORE,
                    MaterialNode::from(frame_time_graph_materials.add(FrametimeGraphMaterial {
                        values: buffers.add(ShaderStorageBuffer {
                            // Initialize with dummy data because the default (`data: None`) will

Review comment (bug):
The bug only happens in webgl so this should only check for that. I think the feature flag is called `webgl2`.

Code after:
}

#[derive(Component)]
struct FpsText;

#[derive(Component)]
struct FrameTimeGraph;

fn setup(
    mut commands: Commands,
    overlay_config: Res<FpsOverlayConfig>,
    mut frame_time_graph_materials: ResMut<Assets<FrametimeGraphMaterial>>,
    mut buffers: ResMut<Assets<ShaderStorageBuffer>>,
) {
    commands
        .spawn((
            Node {
                // We need to make sure the overlay doesn't affect the position of other UI nodes
                position_type: PositionType::Absolute,
                flex_direction: FlexDirection::Column,
                ..Default::default()
            },
            // Render overlay on top of everything
            GlobalZIndex(FPS_OVERLAY_ZINDEX),
            Pickable::IGNORE,
        ))
        .with_children(|p| {
            p.spawn((
                Text::new("FPS: "),
                overlay_config.text_config.clone(),
                TextColor(overlay_config.text_color),
                FpsText,
                Pickable::IGNORE,
            ))
            .with_child((TextSpan::default(), overlay_config.text_config.clone()));

            #[cfg(all(target_arch = "wasm32", not(feature = "webgpu")))]
            {
                if overlay_config.frame_time_graph_config.enabled {
                    use tracing::warn;

                    warn!("Frame time graph is not supported with WebGL. Consider if WebGPU is viable for your usecase.");
                }
            }
            #[cfg(not(all(target_arch = "wasm32", not(feature = "webgpu"))))]
            {
                let font_size = overlay_config.text_config.font_size;
                p.spawn((
                    Node {
                        width: Val::Px(font_size * FRAME_TIME_GRAPH_WIDTH_SCALE),
                        height: Val::Px(font_size * FRAME_TIME_GRAPH_HEIGHT_SCALE),