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

Bevy panics when running empty scene #13235

Closed
s-puig opened this issue May 4, 2024 · 0 comments · Fixed by #13242
Closed

Bevy panics when running empty scene #13235

s-puig opened this issue May 4, 2024 · 0 comments · Fixed by #13242
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Milestone

Comments

@s-puig
Copy link
Contributor

s-puig commented May 4, 2024

Bevy version

main

[Optional] Relevant system information

SystemInfo { os: "Linux 23.10 Ubuntu", kernel: "6.5.0-28-generic", cpu: "Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz", core_count: "4", memory: "23.3 GiB" }
AdapterInfo { name: "AMD Radeon RX 580 Series (RADV POLARIS10)", vendor: 4098, device: 26591, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 23.2.1-1ubuntu3.1", backend: Vulkan }

Happens in both x11 and wayland.

What you did

Run texture_atlas example.

What went wrong

App instantly panicked.

Additional information

Isolated the problem to #12792

Tried to reproduce in a minimal environment and still crashed:

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .run();
}

My guess is that it can't handle a scenario when there aren't any sprites to draw.

Logs thread 'Compute Task Pool (0)' panicked at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5: wgpu error: Validation Error

Caused by:
In Device::create_bind_group
note: label = sprite_view_bind_group
Bound buffer range 0..752 does not fit in buffer of size 0
note: buffer = <Buffer-(7, 1, Vulkan)>

stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: wgpu::backend::wgpu_core::default_error_handler
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5
3: core::ops::function::Fn::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:79:5
4: <alloc::boxed::Box<F,A> as core::ops::function::Fn>::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
5: wgpu::backend::wgpu_core::ErrorSinkRaw::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:2992:17
6: wgpu::backend::wgpu_core::ContextWgpuCore::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:262:9
7: <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:1040:13
8: ::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/context.rs:2236:13
9: wgpu::Device::create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/lib.rs:2431:26
10: bevy_render::renderer::render_device::RenderDevice::create_bind_group
at ./crates/bevy_render/src/renderer/render_device.rs:95:31
11: bevy_sprite::render::prepare_sprites
at ./crates/bevy_sprite/src/render/mod.rs:559:44
12: core::ops::function::FnMut::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:166:5
13: core::ops::function::impls::<impl core::ops::function::FnMut for &mut F>::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:294:13
14: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11) .> Out>>::run::call_inner
at ./crates/bevy_ecs/src/system/function_system.rs:665:21
15: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11) .> Out>>::run
at ./crates/bevy_ecs/src/system/function_system.rs:668:17
16: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
at ./crates/bevy_ecs/src/system/function_system.rs:507:19
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Encountered a panic in system bevy_sprite::render::prepare_sprites!
2024-05-04T16:18:20.544078Z ERROR wgpu::backend::wgpu_core: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5:
wgpu error: Validation Error

Caused by:
In Device::create_bind_group
note: label = ui_view_bind_group
Bound buffer range 0..752 does not fit in buffer of size 0
note: buffer = <Buffer-(7, 1, Vulkan)>

stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: wgpu::backend::wgpu_core::default_error_handler
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5
3: core::ops::function::Fn::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:79:5
4: <alloc::boxed::Box<F,A> as core::ops::function::Fn>::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
5: wgpu::backend::wgpu_core::ErrorSinkRaw::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:2992:17
6: wgpu::backend::wgpu_core::ContextWgpuCore::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:262:9
7: <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:1040:13
8: ::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/context.rs:2236:13
9: wgpu::Device::create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/lib.rs:2431:26
10: bevy_render::renderer::render_device::RenderDevice::create_bind_group
at ./crates/bevy_render/src/renderer/render_device.rs:95:31
11: bevy_ui::render::prepare_uinodes
at ./crates/bevy_ui/src/render/mod.rs:951:40
12: core::ops::function::FnMut::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:166:5
13: core::ops::function::impls::<impl core::ops::function::FnMut for &mut F>::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:294:13
14: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11) .> Out>>::run::call_inner
at ./crates/bevy_ecs/src/system/function_system.rs:665:21
15: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11) .> Out>>::run
at ./crates/bevy_ecs/src/system/function_system.rs:668:17
16: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
at ./crates/bevy_ecs/src/system/function_system.rs:507:19
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Encountered a panic in system bevy_ui::render::prepare_uinodes!
2024-05-04T16:18:20.548270Z ERROR wgpu::backend::wgpu_core: Handling wgpu errors as fatal by default
thread 'main' panicked at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5:
wgpu error: Validation Error

Caused by:
In Device::create_bind_group
note: label = prepass_view_no_motion_vectors_bind_group
Bound buffer range 0..752 does not fit in buffer of size 0
note: buffer = <Buffer-(7, 1, Vulkan)>

stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: wgpu::backend::wgpu_core::default_error_handler
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5
3: core::ops::function::Fn::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:79:5
4: <alloc::boxed::Box<F,A> as core::ops::function::Fn>::call
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
5: wgpu::backend::wgpu_core::ErrorSinkRaw::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:2992:17
6: wgpu::backend::wgpu_core::ContextWgpuCore::handle_error
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:262:9
7: <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:1040:13
8: ::device_create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/context.rs:2236:13
9: wgpu::Device::create_bind_group
at /home/puig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/lib.rs:2431:26
10: bevy_render::renderer::render_device::RenderDevice::create_bind_group
at ./crates/bevy_render/src/renderer/render_device.rs:95:31
11: bevy_pbr::prepass::prepare_prepass_view_bind_group
at ./crates/bevy_pbr/src/prepass/mod.rs:679:58
12: core::ops::function::FnMut::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:166:5
13: core::ops::function::impls::<impl core::ops::function::FnMut for &mut F>::call_mut
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:294:13
14: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5) .> Out>>::run::call_inner
at ./crates/bevy_ecs/src/system/function_system.rs:665:21
15: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5) .> Out>>::run
at ./crates/bevy_ecs/src/system/function_system.rs:668:17
16: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
at ./crates/bevy_ecs/src/system/function_system.rs:507:19
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Encountered a panic in system bevy_pbr::prepass::prepare_prepass_view_bind_group<bevy_pbr::pbr_material::StandardMaterial>!

@s-puig s-puig added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@mockersf mockersf added this to the 0.14 milestone May 4, 2024
@mockersf mockersf added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels May 4, 2024
github-merge-queue bot pushed a commit that referenced this issue May 5, 2024
# Objective

- `DynamicUniformBuffer` tries to create a buffer as soon as the changed
flag is set to true. This doesn't work correctly when the buffer wasn't
already created. This currently creates a crash because it's trying to
create a buffer of size 0 if the flag is set but there's no buffer yet.

## Solution

- Don't create a changed buffer until there's data that needs to be
written to a buffer.

## Testing

- run `cargo run --example scene_viewer` and see that it doesn't crash
anymore

Fixes #13235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants