bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.23k stars 3.57k forks source link

Resizing causes a crash on latest stable Nvidia driver 550 #12199

Closed eero-lehtinen closed 7 months ago

eero-lehtinen commented 8 months ago

Bevy version

Affects both 0.13 and main (21adeb684261eacd39acecaa8b056e0b9e918268)

Relevant system information

cargo 1.76.0 (c84b36747 2024-01-18)
KDE desktop X11
AdapterInfo { name: "NVIDIA GeForce RTX 3070 Ti", vendor: 4318, device: 9346, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "550.54.14", backend: Vulkan }
SystemInfo { os: "Linux rolling EndeavourOS", kernel: "6.7.6-arch1-1", cpu: "AMD Ryzen 7 5800X3D 8-Core Processor", core_count: "8", memory: "31.3 GiB" }

What you did

Run cargo run --example window_resizing or pretty much any example. Then drag a window corner to resize.

What went wrong

Outputs this and crashes.

thread 'Compute Task Pool (6)' panicked at crates/bevy_render/src/view/window/mod.rs:357:26:
Error reconfiguring surface: Outdated
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
thread 'Compute Task Pool (1)' panicked at crates/bevy_render/src/pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError

Additional information

550 was very recently stabilized (https://www.phoronix.com/news/NVIDIA-550.54.14-Linux-Driver).

Everything starts working again if I downgrade to the 545 driver.

I tested an example from the winit repository cargo run --example window and there was no issues.

Other applications I use aren't affected by this issue, so it might not be Nvidia's fault.

Complete log of the bevy example with backtrace:

❯ RUST_BACKTRACE=1 cargo run --example window_resizing
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/examples/window_resizing`
2024-02-29T12:17:29.654613Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-02-29T12:17:29.654883Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1.1666666666666667    
2024-02-29T12:17:29.722909Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3070 Ti", vendor: 4318, device: 9346, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "550.54.14", backend: Vulkan }
2024-02-29T12:17:30.120325Z  INFO gilrs_core::platform::platform::gamepad: Gamepad /dev/input/event9 (Generic X-Box pad) connected.    
2024-02-29T12:17:30.203046Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux rolling EndeavourOS", kernel: "6.7.6-arch1-1", cpu: "AMD Ryzen 7 5800X3D 8-Core Processor", core_count: "8", memory: "31.3 GiB" }
2024-02-29T12:17:30.215488Z  INFO bevy_input::gamepad: Gamepad { id: 0 } Connected
thread 'Compute Task Pool (6)' panicked at crates/bevy_render/src/view/window/mod.rs:357:26:
Error reconfiguring surface: Outdated
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
   3: core::result::Result<T,E>::expect
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1030:23
   4: bevy_render::view::window::prepare_windows
             at ./crates/bevy_render/src/view/window/mod.rs:355:33
   5: core::ops::function::FnMut::call_mut
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:166:5
   6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13
   7: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8) .> Out>>::run::call_inner
             at ./crates/bevy_ecs/src/system/function_system.rs:661:21
   8: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1,F2,F3,F4,F5,F6,F7,F8) .> Out>>::run
             at ./crates/bevy_ecs/src/system/function_system.rs:664:17
   9: <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:504:19
  10: bevy_ecs::schedule::executor::multi_threaded::ExecutorState::spawn_system_task::{{closure}}::{{closure}}
             at ./crates/bevy_ecs/src/schedule/executor/multi_threaded.rs:621:26
  11: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  12: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
  13: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  14: __rust_try
  15: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  16: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  17: bevy_ecs::schedule::executor::multi_threaded::ExecutorState::spawn_system_task::{{closure}}
             at ./crates/bevy_ecs/src/schedule/executor/multi_threaded.rs:614:23
  18: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:297:9
  19: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:588:42
  20: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
  21: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  22: __rust_try
  23: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  24: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  25: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:588:9
  26: async_executor::Executor::spawn::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:158:20
  27: async_task::raw::RawTask<F,T,S,M>::run::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:550:21
  28: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  29: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
  30: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  31: __rust_try
  32: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  33: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  34: async_task::raw::RawTask<F,T,S,M>::run
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:549:23
  35: async_task::runnable::Runnable<M>::run
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781:18
  36: async_executor::Executor::run::{{closure}}::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:254:21
  37: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:449:33
  38: async_executor::Executor::run::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:261:32
  39: futures_lite::future::block_on::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:99:19
  40: std::thread::local::LocalKey<T>::try_with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  41: std::thread::local::LocalKey<T>::with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  42: futures_lite::future::block_on
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:78:5
  43: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:180:37
  44: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  45: __rust_try
  46: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  47: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  48: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:174:43
  49: std::thread::local::LocalKey<T>::try_with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  50: std::thread::local::LocalKey<T>::with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  51: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:167:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
thread 'Compute Task Pool (0)' panicked at crates/bevy_render/src/pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1073:23
   4: bevy_render::pipelined_rendering::RenderAppChannels::recv::{{closure}}
             at ./crates/bevy_render/src/pipelined_rendering.rs:49:26
   5: bevy_render::pipelined_rendering::update_rendering::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at ./crates/bevy_render/src/pipelined_rendering.rs:185:60
   6: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:297:9
   7: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:588:42
   8: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
   9: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  10: __rust_try
  11: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  12: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  13: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:588:9
  14: async_executor::Executor::spawn::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:158:20
  15: async_task::raw::RawTask<F,T,S,M>::run::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:550:21
  16: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  17: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
  18: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  19: __rust_try
  20: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  21: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  22: async_task::raw::RawTask<F,T,S,M>::run
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:549:23
  23: async_task::runnable::Runnable<M>::run
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781:18
  24: async_executor::Executor::run::{{closure}}::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:254:21
  25: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:449:33
  26: async_executor::Executor::run::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.8.0/src/lib.rs:261:32
  27: futures_lite::future::block_on::{{closure}}
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:99:19
  28: std::thread::local::LocalKey<T>::try_with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  29: std::thread::local::LocalKey<T>::with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  30: futures_lite::future::block_on
             at /home/eero/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.2.0/src/future.rs:78:5
  31: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:180:37
  32: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  33: __rust_try
  34: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  35: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  36: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:174:43
  37: std::thread::local::LocalKey<T>::try_with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  38: std::thread::local::LocalKey<T>::with
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  39: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
             at ./crates/bevy_tasks/src/task_pool.rs:167:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
alice-i-cecile commented 8 months ago

Can you reproduce this upstream on winit's examples? If so, please open an issue there and link this issue for us <3

tim-blackbird commented 8 months ago

They mention testing a winit example:

I tested an example from the winit repository cargo run --example window and there was no issues.

It might be reproducible on wgpu instead

eero-lehtinen commented 8 months ago

Yep I tested winit upstream examples and found no issues. Now I also tested wgpu upstream examples and found no issues. Seems Bevy specific.

eero-lehtinen commented 8 months ago

I tested older versions of bevy and it looks like 0.9 is the latest version that works

eero-lehtinen commented 8 months ago

Bisected the issue to the introduction of pipelined rendering 2027af4c54082007fed2091f112a11cb0bc5fc08 :)

alice-i-cecile commented 8 months ago

FYI @james7132 @hymm. Thanks a ton for bisecting!

eero-lehtinen commented 8 months ago

Also works on main if I disable the multi-threading feature as it disables pipelined rendering.

StarArawn commented 8 months ago

I just ran into this myself. Arch linux with nvidia drivers 550.54.14-2.

DissolveDZ commented 8 months ago

I have the same issue on the newest nvidia drivers and X11

DissolveDZ commented 8 months ago

Also works on main if I disable the multi-threading feature as it disables pipelined rendering.

after disabling multithreading i'm getting the following error:

thread 'main' panicked at /home/colin/.cargo/registry/s
c/index.crates.io-6f17d22bba15001f/bevy_render-0.13.0/s
c/view/window/mod.rs:346:18:
Error configuring surface: Outdated
note: run with `RUST_BACKTRACE=1` environment variable 
o display a backtrace
Encountered a panic in system `bevy_render::view::windo
::prepare_windows`!
443eb9 commented 8 months ago

I'm also suffering from this issue:

``` $ export RUST_BACKTRACE=1;cargo run --example=basic Finished dev [optimized + debuginfo] target(s) in 0.12s Running `target/debug/examples/basic` 2024-03-06T10:59:10.946677Z WARN log: error setting XSETTINGS; Xft options won't reload automatically 2024-03-06T10:59:10.952237Z INFO bevy_winit::system: Creating new window "App" (0v1) 2024-03-06T10:59:10.952382Z INFO log: Guessed window scale factor: 1.25 2024-03-06T10:59:11.020781Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3070", vendor: 4318, device: 9352, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "550.54.14", backend: Vulkan } 2024-03-06T10:59:11.174584Z WARN bevy_inspector_egui::inspector_options::default_options: Attempting to set default inspector options for bevy_pbr::light::AmbientLight, but it wasn't registered in the type registry. 2024-03-06T10:59:11.174597Z WARN bevy_inspector_egui::inspector_options::default_options: Attempting to set default inspector options for bevy_pbr::light::PointLight, but it wasn't registered in the type registry. 2024-03-06T10:59:11.174599Z WARN bevy_inspector_egui::inspector_options::default_options: Attempting to set default inspector options for bevy_pbr::light::DirectionalLight, but it wasn't registered in the type registry. 2024-03-06T10:59:11.174602Z WARN bevy_inspector_egui::inspector_options::default_options: Attempting to set default inspector options for bevy_pbr::pbr_material::StandardMaterial, but it wasn't registered in the type registry. 2024-03-06T10:59:11.174608Z WARN bevy_inspector_egui::inspector_options::default_options: Attempting to set default inspector options for bevy_pbr::light::ClusterConfig, but it wasn't registered in the type registry. 2024-03-06T10:59:11.188188Z INFO system{name="bevy_diagnostic::system_information_diagnostics_plugin::internal::log_system_info"}: bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux rolling Arch Linux", kernel: "6.7.8-arch1-1", cpu: "Intel(R) Core(TM) i5-10600KF CPU @ 4.10GHz", core_count: "6", memory: "31.3 GiB" } 0: bevy_ecs::system::function_system::system with name="bevy_render::view::window::prepare_windows" at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/system/function_system.rs:47 thread 'main' panicked at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.13.0/src/view/window/mod.rs:346:18: Error configuring surface: Outdated stack backtrace: 0: rust_begin_unwind at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5 1: core::panicking::panic_fmt at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14 2: core::result::unwrap_failed at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5 3: core::result::Result::expect at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1030:23 4: bevy_render::view::window::prepare_windows 5: core::ops::function::FnMut::call_mut at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:166:5 6: core::ops::function::impls:: for &mut F>::call_mut at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13 7: Out>>::run::call_inner at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/system/function_system.rs:656:21 8: Out>>::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/system/function_system.rs:659:17 9: as bevy_ecs::system::system::System>::run_unsafe at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/system/function_system.rs:499:19 10: bevy_ecs::system::system::System::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/system/system.rs:76:18 11: ::run::{{closure}} at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/schedule/executor/single_threaded.rs:101:21 12: core::ops::function::FnOnce::call_once at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5 13: as core::ops::function::FnOnce<()>>::call_once at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9 14: std::panicking::try::do_call at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40 15: std::panicking::try at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19 16: std::panic::catch_unwind at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14 17: ::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/schedule/executor/single_threaded.rs:100:27 18: bevy_ecs::schedule::schedule::Schedule::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/schedule/schedule.rs:344:9 19: bevy_ecs::world::World::run_schedule::{{closure}} at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/world/mod.rs:2306:51 20: bevy_ecs::world::World::try_schedule_scope at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/world/mod.rs:2225:21 21: bevy_ecs::world::World::schedule_scope at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/world/mod.rs:2277:9 22: bevy_ecs::world::World::run_schedule at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.0/src/world/mod.rs:2306:9 23: bevy_app::app::SubApp::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.13.0/src/app.rs:164:24 24: bevy_app::app::App::update at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.13.0/src/app.rs:269:13 25: bevy_winit::run_app_update_if_should at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_winit-0.13.0/src/lib.rs:727:9 26: bevy_winit::handle_winit_event at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_winit-0.13.0/src/lib.rs:607:21 27: bevy_winit::winit_runner::{{closure}} at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_winit-0.13.0/src/lib.rs:281:9 28: core::ops::function::impls:: for &mut F>::call_mut at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13 29: core::ops::function::impls:: for &mut F>::call_mut at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13 30: winit::platform_impl::platform::x11::EventLoop::single_iteration at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/x11/mod.rs:599:17 31: winit::platform_impl::platform::x11::EventLoop::poll_events_with_timeout at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/x11/mod.rs:538:9 32: winit::platform_impl::platform::x11::EventLoop::pump_events at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/x11/mod.rs:444:13 33: winit::platform_impl::platform::x11::EventLoop::run_on_demand at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/x11/mod.rs:405:19 34: winit::platform_impl::platform::EventLoop::run_on_demand at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/mod.rs:829:56 35: winit::platform_impl::platform::EventLoop::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/platform_impl/linux/mod.rs:822:9 36: winit::event_loop::EventLoop::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.11/src/event_loop.rs:249:9 37: bevy_winit::winit_runner at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_winit-0.13.0/src/lib.rs:296:34 38: core::ops::function::FnOnce::call_once at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5 39: core::ops::function::FnOnce::call_once{{vtable.shim}} at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5 40: as core::ops::function::FnOnce>::call_once at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9 41: bevy_app::app::App::run at /home/443eb9/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.13.0/src/app.rs:308:9 42: basic::main at ./examples/basic.rs:28:5 43: core::ops::function::FnOnce::call_once at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. Encountered a panic in system `bevy_render::view::window::prepare_windows`! ```
eero-lehtinen commented 8 months ago

I did some more investigation and found that we call surface.get_current_texture() directly after WindowEvent::Resized, while wgpu examples only do it on WindowEvent::RedrawRequested. If I modify the wgpu examples to do that, they crash too.

alice-i-cecile commented 8 months ago

Excellent digging. I'd be happy to review a PR that changes this behavior in Bevy: it sounds like we're doing work overly eagerly for no real benefit.

eero-lehtinen commented 8 months ago

I'm not actually sure if our code is too eager. It's just that with this specific driver surface.get_current_texture doesn't work if called just after surface.configure (or it works once at startup but not on resize). Maybe as a workaround we could skip drawing a frame on resize? I'm not really familiar with bevy or wgpu internals though, just testing stuff out.

theHamsta commented 8 months ago
2024-03-06T20:26:51.531143Z DEBUG present_frames: wgpu_core::present: Removing swapchain texture Id(12,115,vk) from the device tracker    
2024-03-06T20:26:51.549641Z DEBUG present_frames: wgpu_core::present: Presented. End of Frame    
2024-03-06T20:26:51.550759Z DEBUG wgpu_core::device::global: configuring surface with SurfaceConfiguration { usage: TextureUsages(RENDER_ATTACHMENT), format: Bgra8UnormSrgb, width: 1493, height: 840, present_mode: Fifo, desired_maximum_frame_latency: 2, alpha_mode: Auto, view_formats: [] }    
2024-03-06T20:26:51.550953Z  WARN wgpu_hal::vulkan::conv: Unrecognized present mode 1000361000    
2024-03-06T20:26:51.551007Z DEBUG wgpu_core::device::life: Active submission 229 is done    
VUID-VkSwapchainCreateInfoKHR-pNext-07781(ERROR / SPEC): msgNum: 1284057537 - Validation Error: [ VUID-VkSwapchainCreateInfoKHR-pNext-07781 ] | MessageID = 0x4c8929c1 | vkCreateSwapchainKHR(): pCreateInfo->imageExtent (1493, 840), which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (1477,826), minImageExtent = (1477,826), maxImageExtent = (1477,826). The Vulkan spec states: If a VkSwapchainPresentScalingCreateInfoEXT structure was not included in the pNext chain, or it is included and VkSwapchainPresentScalingCreateInfoEXT::scalingBehavior is zero then imageExtent must be between minImageExtent and maxImageExtent, inclusive, where minImageExtent and maxImageExtent are members of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-pNext-07781)
    Objects: 0
2024-03-06T20:26:51.559037Z  INFO wgpu_hal::vulkan::instance: GENERAL [NVIDIA (0x4)]
        Requested image extent (1493x840) does not match surface (1477x826), marking swapchain out of date    
2024-03-06T20:26:51.559068Z  INFO wgpu_hal::vulkan::instance:   objects: (type: SWAPCHAIN_KHR, hndl: 0x7e7f1801b060, name: ?)    
thread 'Compute Task Pool (3)' panicked at crates/bevy_render/src/view/window/mod.rs:324:26:
Error reconfiguring surface: Outdated
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
thread 'Compute Task Pool (7)' panicked at crates/bevy_render/src/pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError

I get this error when running with validation layers. Though all vk calls return success.

mockersf commented 8 months ago

I did some more investigation and found that we call surface.get_current_texture() directly after WindowEvent::Resized, while wgpu examples only do it on WindowEvent::RedrawRequested. If I modify the wgpu examples to do that, they crash too.

surface.get_current_texture() is called in the render app, so it's mostly unrelated to the order Bevy receives events from winit

eero-lehtinen commented 8 months ago

surface.get_current_texture() is called in the render app, so it's mostly unrelated to the order Bevy receives events from winit

I guess what I should have said is that we call both surface.configure and surface.get_current_texture at the same time in the render app after the window size has changed, while wgpu examples call them in separate winit events (Resized and RedrawRequested). That maybe gives the driver enough time to finish processing and not error out, at least it doesn't crash. Though using events like that might not be applicable in the bevy architecture.

mockersf commented 8 months ago

@eero-lehtinen could you try with this branch? https://github.com/mockersf/bevy/tree/nvidia-outdated

I'm not sure how that will behave, it may fix the issue or make it worse 😄

eero-lehtinen commented 8 months ago

@eero-lehtinen could you try with this branch? https://github.com/mockersf/bevy/tree/nvidia-outdated

Looks like that just works :D. I think I also at some point tried just blindly returning but had bad results, but your version is fine.

Though was that previous retrying behaviour needed on other platforms? wgpu examples do it too.

eero-lehtinen commented 8 months ago

I ported the fix to my game and there are definitely still situations where it can crash. E.g. switching between fullscreen and windowed quickly at startup and resizing the window when it is one of the two windows tiled side by side. The error is the same.

eero-lehtinen commented 8 months ago

It seems to break when there are resizes in consecutive frames, as the outdated error is ignored only in the code path where there is no resize. I made a version where the outdated error is always ignored, and that seems to work perfectly. https://github.com/eero-lehtinen/bevy/tree/v0.13.0-nvidia-fix

zentasumu commented 8 months ago

Under arch linux, using nvidia driver version 550.54.14-4, with Xwayland.

Testing winit 0.29.14 examples, no issues.

Testing with wgpu 0.19.3 boids example, issue was reproducible.

[2024-03-09T04:53:35Z INFO  winit::platform_impl::platform::x11::window] Guessed window scale factor: 1.5
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Initializing wgpu...
[2024-03-09T04:53:35Z INFO  wgpu_core::instance] Adapter Vulkan AdapterInfo { name: "NVIDIA GeForce RTX 3060 Laptop GPU", vendor: 4318, device: 9504, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "550.54.14", backend: Vulkan }
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Using NVIDIA GeForce RTX 3060 Laptop GPU (Vulkan)
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Entering event loop...
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Surface resume PhysicalSize { width: 800, height: 600 }
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 800, height: 600 }
[2024-03-09T04:53:35Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 624, height: 1137 }
[2024-03-09T04:53:36Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 800, height: 600 }
[2024-03-09T04:53:36Z INFO  wgpu_examples::framework] Frame time 6.05ms (165.4 FPS)
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Frame time 6.06ms (165.0 FPS)
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 801, height: 600 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 802, height: 600 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 802, height: 602 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 806, height: 605 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 807, height: 605 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 808, height: 606 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 808, height: 607 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 815, height: 613 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 818, height: 615 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 829, height: 621 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 832, height: 622 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 844, height: 628 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 847, height: 630 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 855, height: 636 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 863, height: 640 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 879, height: 651 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 882, height: 654 }
[2024-03-09T04:53:37Z INFO  wgpu_examples::framework] Surface resize PhysicalSize { width: 885, height: 656 }
thread 'main' panicked at 'Failed to acquire next surface texture!: Outdated', examples/src/framework.rs:235:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
jake8655 commented 8 months ago

It seems to break when there are resizes in consecutive frames, as the outdated error is ignored only in the code path where there is no resize. I made a version where the outdated error is always ignored, and that seems to work perfectly. https://github.com/eero-lehtinen/bevy/tree/v0.13.0-nvidia-fix

Tried out your fix, works for me too in XWayland, nvidia drivers v550.54.14

notverymoe commented 8 months ago

It seems to break when there are resizes in consecutive frames, as the outdated error is ignored only in the code path where there is no resize. I made a version where the outdated error is always ignored, and that seems to work perfectly. https://github.com/eero-lehtinen/bevy/tree/v0.13.0-nvidia-fix

This appears to work for me too. Arch Linux 6.7.9-arch1-1, i3, X11, Nvidia 550.54.14.