Skip to content
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

100% CPU on very simple scene #14359

Closed
bbasics opened this issue Jul 17, 2024 · 5 comments
Closed

100% CPU on very simple scene #14359

bbasics opened this issue Jul 17, 2024 · 5 comments
Labels
C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times O-Linux Specific to the Linux desktop operating system S-Blocked This cannot move forward until something else changes S-Duplicate This issue or PR already exists

Comments

@bbasics
Copy link

bbasics commented Jul 17, 2024

Bevy version

0.14.0

[Optional] Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

Rust: rustc 1.79.0 (129f3b996 2024-06-10)
Linux: Linux mars 5.19.0-38-generic #39~22.04.1-Ubuntu
CPU: AMD® Ryzen 5 5600x
GPU: Nvidia GeForce RTX 3060 Ti

Cargo.toml:

[package]
name = "first_game"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.14.0", features = ["dynamic_linking", "bevy_dev_tools"] }
bevy_dev_tools = "0.14.0"
bevy_mod_picking = { version = "0.20.1", features = ["debug"]}

# Enable a small amount of optimization in debug mode.
[profile.dev]
opt-level = 1

# Enable a large amount of optimization in debug mode for dependencies.
[profile.dev.package."*"]
opt-level = 3

# Enable more optimization in release mode at the cost of compile time.
[profile.release]
# Compile the entire crate as one unit.
# Significantly slows compile times, marginal improvements.
codegen-units = 1
# Do a second optimization pass over the entire program, including dependencies.
# Slightly slows compile times, marginal improvements.
lto = "thin"

# Optimize for size in wasm-release mode to reduce load times and bandwidth usage on web.
[profile.wasm-release]
# Use release profile as default values.
inherits = "release"
# Optimize with size in mind (also try "s", sometimes it is better).
# This doesn't increase compilation times compared to -O3, great improvements.
opt-level = "z"
# Strip all debugging information from the binary to reduce file size.
strip = "debuginfo"

What you did

use bevy::prelude::*;
use bevy_mod_picking::prelude::*;

fn main() {
    let mut app = App::new();
    app.add_plugins(DefaultPlugins);
    app.add_systems(Startup, setup);
    app.add_plugins(DefaultPickingPlugins);
    app.run();
}

#[derive(Component)]
struct Cube {
    click_counter: u32,
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    // Cube
    commands.spawn((
        PbrBundle {
            mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
            material: materials.add(Color::srgb_u8(124, 144, 255)),
            transform: Transform::from_xyz(0.0, 0.5, 0.0),
            ..default()
        },
        Cube { click_counter: 0 },
        On::<Pointer<Click>>::target_component_mut::<Cube>(|event, cube| {
            cube.click_counter += 1;
            println!(
                "Clicked on {:?} times {}",
                event.target(),
                cube.click_counter
            );
        }),
    ));
    // Light
    commands.spawn(PointLightBundle {
        point_light: PointLight {
            shadows_enabled: true,
            ..default()
        },
        transform: Transform::from_xyz(4.0, 8.0, 4.0),
        ..default()
    });
    // Camera
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..default()
    });
}

What went wrong

When I move the mouse, I got 100% CPU usage on this very simple scene. I would expect a very low usage.

image

I that normal? thanks in advance!

@bbasics bbasics added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 17, 2024
@TrialDragon TrialDragon added C-Performance A change motivated by improving speed, memory usage or compile times S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Jul 17, 2024
@janhohenheim
Copy link
Member

janhohenheim commented Jul 17, 2024

Are you using X11 or Wayland? If X, what happens when you switch to Wayland?
Might be related to #14303

@bbasics
Copy link
Author

bbasics commented Jul 18, 2024

Are you using X11 or Wayland? If X, what happens when you switch to Wayland? Might be related to #14303

I am on X11 indeed. However I did not succeed switching to wayland yet. Seems like it is nvidia related, I'll take a deeper look when I have the time. I suppose it should not do that for X11 though.

@janhohenheim
Copy link
Member

@bbasics agreed, just want to know if this is the same issue or a new one :)
The users reporting the referenced problem on X11 were also using Nvidia, while a user using AMD could not reproduce them. If would get Wayland working, it would point towards Nvidia being the common factor.

@bbasics
Copy link
Author

bbasics commented Jul 18, 2024

I upgraded my nvidia driver to 555 and switched to wayland and the CPU stays under 30%. So this seems to be a X11 issue indeed.

@janhohenheim
Copy link
Member

Closing as a duplicate then. Thanks for investigating!

@janhohenheim janhohenheim closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@TimJentzsch TimJentzsch added S-Duplicate This issue or PR already exists O-Linux Specific to the Linux desktop operating system S-Blocked This cannot move forward until something else changes and removed S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times O-Linux Specific to the Linux desktop operating system S-Blocked This cannot move forward until something else changes S-Duplicate This issue or PR already exists
Projects
None yet
Development

No branches or pull requests

4 participants