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

Screen blanking causes panic on Linux/X11 #4579

Closed
mdickopp opened this issue Apr 24, 2022 · 8 comments
Closed

Screen blanking causes panic on Linux/X11 #4579

mdickopp opened this issue Apr 24, 2022 · 8 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system P-Crash A sudden unexpected crash

Comments

@mdickopp
Copy link
Contributor

Bevy version

main branch, commit 46acb77.

Operating system & version

Linux (Debian 12 “Bookworm”), X11

Xfce 4.16 with light-locker as the screensaver

AMD Radeon RX 590 Series (POLARIS10, DRM 3.44.0, 5.16.0-6-amd64, LLVM 13.0.1)

What you did

  • Run a bevy program that uses present_mode: bevy::window::PresentMode::Fifo.
  • Activate screen blanking or wait for the screensaver to activate it. Using light-locker, I used the command sleep 1; light-locker-command -a. (The purpose of sleep 1 is to prevent the release of the return key when issuing the command from deactivating the screen blanking immediately.)
  • Wait a few seconds.
  • Deactivate screen blanking (e.g. by moving the mouse).

What you expected to happen

The program should still be running.

What actually happened

The program panics with message “Failed to acquire next swap chain texture!: Timeout” in bevy_render/src/view/window.rs:161.

Additional information

Log:

    Finished dev [optimized + debuginfo] target(s) in 0.08s
     Running `target/debug/railroad-aura`
2022-04-24T16:32:01.523811Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 3.1666666666666665
2022-04-24T16:32:01.553940Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD RADV POLARIS10", vendor: 4098, device: 26591, device_type: DiscreteGpu, backend: Vulkan }
2022-04-24T16:32:02.931428Z  INFO bevy diagnostic: frame_time                      :    0.016797s (avg 0.016661s)
2022-04-24T16:32:02.931503Z  INFO bevy diagnostic: fps                             :   60.021653  (avg 59.989119)
2022-04-24T16:32:02.931526Z  INFO bevy diagnostic: frame_count                     :   64.000000  (avg 64.000000)
2022-04-24T16:32:03.931307Z  INFO bevy diagnostic: frame_time                      :    0.016842s (avg 0.016665s)
2022-04-24T16:32:03.931345Z  INFO bevy diagnostic: fps                             :   60.007385  (avg 59.999148)
2022-04-24T16:32:03.931357Z  INFO bevy diagnostic: frame_count                     :  124.000000  (avg 124.000000)
2022-04-24T16:32:04.931456Z  INFO bevy diagnostic: frame_time                      :    0.016699s (avg 0.016667s)
2022-04-24T16:32:04.931552Z  INFO bevy diagnostic: fps                             :   59.998868  (avg 60.002480)
2022-04-24T16:32:04.931566Z  INFO bevy diagnostic: frame_count                     :  184.000000  (avg 184.000000)
2022-04-24T16:32:05.931107Z  INFO bevy diagnostic: frame_time                      :    0.016471s (avg 0.016656s)
2022-04-24T16:32:05.931144Z  INFO bevy diagnostic: fps                             :   60.036713  (avg 59.999736)
2022-04-24T16:32:05.931155Z  INFO bevy diagnostic: frame_count                     :  244.000000  (avg 244.000000)
2022-04-24T16:32:06.930850Z  INFO bevy diagnostic: frame_time                      :    0.016697s (avg 0.016661s)
2022-04-24T16:32:06.930892Z  INFO bevy diagnostic: fps                             :   60.021312  (avg 59.973087)
2022-04-24T16:32:06.930904Z  INFO bevy diagnostic: frame_count                     :  304.000000  (avg 304.000000)
2022-04-24T16:32:07.930875Z  INFO bevy diagnostic: frame_time                      :    0.016647s (avg 0.016664s)
2022-04-24T16:32:07.930914Z  INFO bevy diagnostic: fps                             :   60.009066  (avg 59.996297)
2022-04-24T16:32:07.930926Z  INFO bevy diagnostic: frame_count                     :  364.000000  (avg 364.000000)
2022-04-24T16:32:08.930843Z  INFO bevy diagnostic: frame_time                      :    0.016602s (avg 0.016662s)
2022-04-24T16:32:08.930886Z  INFO bevy diagnostic: fps                             :   60.017949  (avg 60.005827)
2022-04-24T16:32:08.930898Z  INFO bevy diagnostic: frame_count                     :  424.000000  (avg 424.000000)
2022-04-24T16:32:09.930875Z  INFO bevy diagnostic: frame_time                      :    0.016571s (avg 0.016662s)
2022-04-24T16:32:09.930913Z  INFO bevy diagnostic: fps                             :   60.015520  (avg 59.997021)
2022-04-24T16:32:09.930925Z  INFO bevy diagnostic: frame_count                     :  484.000000  (avg 484.000000)
2022-04-24T16:32:10.930922Z  INFO bevy diagnostic: frame_time                      :    0.016650s (avg 0.016668s)
2022-04-24T16:32:10.930982Z  INFO bevy diagnostic: fps                             :   59.996362  (avg 60.001507)
2022-04-24T16:32:10.930997Z  INFO bevy diagnostic: frame_count                     :  544.000000  (avg 544.000000)
thread 'main' panicked at 'Failed to acquire next swap chain texture!: Timeout', /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_render/src/view/window.rs:161:24
stack backtrace:
   0:     0x7996710f986d - std::backtrace_rs::backtrace::libunwind::trace::hee598835bc88d35b
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7996710f986d - std::backtrace_rs::backtrace::trace_unsynchronized::h9cdc730ba5cf5d72
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7996710f986d - std::sys_common::backtrace::_print_fmt::h75aeaf7ed30e43fa
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7996710f986d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h606862f787600875
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7996711594ec - core::fmt::write::he803f0f418caf762
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/fmt/mod.rs:1190:17
   5:     0x7996710e9a98 - std::io::Write::write_fmt::h70bc45872f37e7bb
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/io/mod.rs:1657:15
   6:     0x7996710fd847 - std::sys_common::backtrace::_print::h64d038cf8ac3e13e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7996710fd847 - std::sys_common::backtrace::print::h359300b4a7fccf65
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7996710fd847 - std::panicking::default_hook::{{closure}}::hf51be35e2f510149
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:295:22
   9:     0x7996710fd510 - std::panicking::default_hook::h03ca0f22e1d2d25e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:314:9
  10:     0x7996710fe0e9 - std::panicking::rust_panic_with_hook::h3b7380e99b825b63
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:698:17
  11:     0x7996710fddd7 - std::panicking::begin_panic_handler::{{closure}}::h8e849d0710154ce0
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:588:13
  12:     0x7996710f9d34 - std::sys_common::backtrace::__rust_end_short_backtrace::hedcdaddbd4c46cc5
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x7996710fdae9 - rust_begin_unwind
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
  14:     0x7996710c6863 - core::panicking::panic_fmt::he1bbc7336d49a357
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
  15:     0x7996710c6953 - core::result::unwrap_failed::h719f957ed74f93fd
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1749:5
  16:     0x7996722e00bf - core::result::Result<T,E>::expect::h0f54b19a598f1ad2
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1022:23
  17:     0x7996722e00bf - bevy_render::view::window::prepare_windows::h5fd6f7a0477f91a3
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_render/src/view/window.rs:161:20
  18:     0x7996722dbbf3 - core::ops::function::FnMut::call_mut::h704bd5f101b3b994
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:150:5
  19:     0x7996722dbbf3 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h67ef84e2a8ed49bd
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:269:13
  20:     0x7996722dbbf3 - <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,F1,F2,F3,F4),()>>::run::call_inner::h740e3493c1469c5a
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/system/function_system.rs:505:21
  21:     0x7996722dbbf3 - <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,F1,F2,F3,F4),()>>::run::h8d4fde6d26be4f19
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/system/function_system.rs:508:17
  22:     0x7996722dbbf3 - <bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::h6fbc86d5a30d1088
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/system/function_system.rs:379:19
  23:     0x799672e66f5d - bevy_ecs::schedule::executor_parallel::ParallelExecutor::prepare_systems::{{closure}}::h9c213b8f0a699d5e
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/schedule/executor_parallel.rs:196:30
  24:     0x799672e66f5d - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h65367bceac9c1619
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19
  25:     0x799672e67358 - async_executor::LocalExecutor::spawn::{{closure}}::h73f3251fd71f7890
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:376:19
  26:     0x799672e67358 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h6f05f53a95240d26
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19
  27:     0x799672e46f13 - async_task::raw::RawTask<F,T,S>::run::h75f1c3781ba0896b
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/async-task-4.2.0/src/raw.rs:489:20
  28:     0x799672e76a13 - async_executor::Executor::try_tick::hb669b5f7163d9c86
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:181:17
  29:     0x799672e76a13 - async_executor::LocalExecutor::try_tick::h6c5026de5d420c4f
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:405:9
  30:     0x799672e25e43 - bevy_tasks::task_pool::TaskPool::scope::{{closure}}::h7b3f87c4ab8bbbef
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_tasks/src/task_pool.rs:234:21
  31:     0x799672e25e43 - std::thread::local::LocalKey<T>::try_with::h1606492527821a58
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:413:16
  32:     0x799672e25e43 - std::thread::local::LocalKey<T>::with::h0fa145c31305e30d
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:389:9
  33:     0x799672e25e43 - bevy_tasks::task_pool::TaskPool::scope::h22353b5ca16b644f
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_tasks/src/task_pool.rs:180:9
  34:     0x799672e3bf82 - <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::h1c6bc5f54d1b1d40
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/schedule/executor_parallel.rs:129:9
  35:     0x799672e58a32 - <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::hbac333403c4b29f2
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_ecs/src/schedule/stage.rs:852:17
  36:     0x79967236bbd9 - <bevy_render::RenderPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::h002ee45429a6d330
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_render/src/lib.rs:223:21
  37:     0x799672e1682b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h253d5360d7fcd567
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1867:9
  38:     0x799672e1682b - bevy_app::app::App::update::h18b4ef26aa2eb128
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_app/src/app.rs:116:13
  39:     0x799671a21b32 - bevy_winit::winit_runner_with::{{closure}}::h557c6eb7d7f2aaf0
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_winit/src/lib.rs:563:21
  40:     0x799671a3e3ea - winit::platform_impl::platform::sticky_exit_callback::hdad831ee997a74d6
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:753:5
  41:     0x799671a3e3ea - winit::platform_impl::platform::x11::EventLoop<T>::run_return::h757e1037e23767a0
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:293:17
  42:     0x799671a3ec4d - winit::platform_impl::platform::x11::EventLoop<T>::run::h67f31800d30e82f4
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:392:9
  43:     0x799671a2601c - winit::platform_impl::platform::EventLoop<T>::run::h83f4566cd9ba2974
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:669:56
  44:     0x799671a563ec - winit::event_loop::EventLoop<T>::run::hf3bab02aaf40b56b
                               at /home/martin/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/winit-0.26.1/src/event_loop.rs:154:9
  45:     0x799671a54fcc - bevy_winit::run::h52cb6f4bf7996f3c
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_winit/src/lib.rs:180:5
  46:     0x799671a55b1d - bevy_winit::winit_runner_with::h50c193c7d83e579a
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_winit/src/lib.rs:604:9
  47:     0x799671a3a2a4 - bevy_winit::winit_runner::hae86db36465cdada
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_winit/src/lib.rs:220:5
  48:     0x799671a3a2a4 - core::ops::function::Fn::call::h815a46905e3ba033
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:70:5
  49:     0x799672e16a2b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc44719152755253c
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1867:9
  50:     0x799672e16a2b - bevy_app::app::App::run::hb9825d8d88325541
                               at /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_app/src/app.rs:130:9
  51:     0x59ba7bd1dcb9 - railroad_aura::main::h79b1dc5c896e4d23
                               at /home/martin/incomplete/railroad-aura/src/main.rs:17:5
  52:     0x59ba7bd388b3 - core::ops::function::FnOnce::call_once::hbf410b77f0683686
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
  53:     0x59ba7bd388b3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h264277cc4a79b216
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:122:18
  54:     0x59ba7bd29509 - std::rt::lang_start::{{closure}}::he5f37680e5caab0b
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/rt.rs:145:18
  55:     0x7996710f8ec1 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb7014f43484a8b4e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:259:13
  56:     0x7996710f8ec1 - std::panicking::try::do_call::h7bc9dc436daeb8c7
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
  57:     0x7996710f8ec1 - std::panicking::try::h653d68a27ff5f175
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
  58:     0x7996710f8ec1 - std::panic::catch_unwind::h9d739f9f59895e68
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
  59:     0x7996710f8ec1 - std::rt::lang_start_internal::{{closure}}::hf006f2bc7ce22bbe
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/rt.rs:128:48
  60:     0x7996710f8ec1 - std::panicking::try::do_call::hfb39d6df61a2e69f
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
  61:     0x7996710f8ec1 - std::panicking::try::h13e2d225134958ac
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
  62:     0x7996710f8ec1 - std::panic::catch_unwind::h3bd49b5a5dfb1a50
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
  63:     0x7996710f8ec1 - std::rt::lang_start_internal::h2ba92edce36c035e
                               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/rt.rs:128:20
  64:     0x59ba7bd1dd88 - main
  65:     0x799670d0c7fd - __libc_start_main
                               at ./csu/../csu/libc-start.c:332:16
  66:     0x59ba7bd1482a - _start
  67:                0x0 - <unknown>

This issue does not occur when present_mode: bevy::window::PresentMode::Mailbox or present_mode: bevy::window::PresentMode::Immediate is used.

@mdickopp mdickopp added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 24, 2022
@nicopap
Copy link
Contributor

nicopap commented Apr 24, 2022

Seems similar to #3380 .

@mdickopp
Copy link
Contributor Author

I observe sometimes, but not always, that the framerate drops before the panic occurs. Here is a log excerpt:

2022-04-24T16:57:00.973347Z  INFO bevy diagnostic: frame_time                      :    0.016912s (avg 0.016680s)
2022-04-24T16:57:00.973402Z  INFO bevy diagnostic: fps                             :   59.951500  (avg 60.048423)
2022-04-24T16:57:00.973421Z  INFO bevy diagnostic: frame_count                     :   64.000000  (avg 64.000000)
2022-04-24T16:57:01.973018Z  INFO bevy diagnostic: frame_time                      :    0.016767s (avg 0.016647s)
2022-04-24T16:57:01.973073Z  INFO bevy diagnostic: fps                             :   60.071172  (avg 60.065512)
2022-04-24T16:57:01.973087Z  INFO bevy diagnostic: frame_count                     :  124.000000  (avg 124.000000)
2022-04-24T16:57:02.972733Z  INFO bevy diagnostic: frame_time                      :    0.016667s (avg 0.016658s)
2022-04-24T16:57:02.972788Z  INFO bevy diagnostic: fps                             :   60.032377  (avg 60.004492)
2022-04-24T16:57:02.972804Z  INFO bevy diagnostic: frame_count                     :  184.000000  (avg 184.000000)
2022-04-24T16:57:03.972646Z  INFO bevy diagnostic: frame_time                      :    0.016818s (avg 0.016660s)
2022-04-24T16:57:03.972702Z  INFO bevy diagnostic: fps                             :   60.022510  (avg 60.010782)
2022-04-24T16:57:03.972721Z  INFO bevy diagnostic: frame_count                     :  244.000000  (avg 244.000000)
2022-04-24T16:57:05.186321Z  INFO bevy diagnostic: frame_time                      :    0.812902s (avg 0.057349s)
2022-04-24T16:57:05.186383Z  INFO bevy diagnostic: fps                             :   17.437144  (avg 57.701052)
2022-04-24T16:57:05.186406Z  INFO bevy diagnostic: frame_count                     :  268.000000  (avg 268.000000)
2022-04-24T16:57:06.187697Z  INFO bevy diagnostic: frame_time                      :    1.001201s (avg 0.106575s)
2022-04-24T16:57:06.187747Z  INFO bevy diagnostic: fps                             :    9.383092  (avg 55.168870)
2022-04-24T16:57:06.187761Z  INFO bevy diagnostic: frame_count                     :  269.000000  (avg 269.000000)
2022-04-24T16:57:07.187855Z  INFO bevy diagnostic: frame_time                      :    1.000314s (avg 0.155762s)
2022-04-24T16:57:07.187904Z  INFO bevy diagnostic: fps                             :    6.420057  (avg 52.487073)
2022-04-24T16:57:07.187919Z  INFO bevy diagnostic: frame_count                     :  270.000000  (avg 270.000000)
2022-04-24T16:57:08.186362Z  INFO bevy diagnostic: frame_time                      :    0.998516s (avg 0.204849s)
2022-04-24T16:57:08.186423Z  INFO bevy diagnostic: fps                             :    4.881641  (avg 49.731346)
2022-04-24T16:57:08.186446Z  INFO bevy diagnostic: frame_count                     :  271.000000  (avg 271.000000)
2022-04-24T16:57:09.185337Z  INFO bevy diagnostic: frame_time                      :    0.999289s (avg 0.253974s)
2022-04-24T16:57:09.185363Z  INFO bevy diagnostic: fps                             :    3.937418  (avg 46.929189)
2022-04-24T16:57:09.185372Z  INFO bevy diagnostic: frame_count                     :  272.000000  (avg 272.000000)
thread 'main' panicked at 'Failed to acquire next swap chain texture!: Timeout', /home/martin/.cargo/git/checkouts/bevy-f7ffde730c324c74/46acb77/crates/bevy_render/src/view/window.rs:161:24

@DJMcNab
Copy link
Member

DJMcNab commented Apr 24, 2022

Does this also occur on the wgpu examples?

@DJMcNab DJMcNab added A-Rendering Drawing game state to the screen P-Crash A sudden unexpected crash O-Linux Specific to the Linux desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Apr 24, 2022
@mdickopp
Copy link
Contributor Author

Seems similar to #3380.

I can reproduce #3380 with my setup and hardware. However, a difference is that import causes the panic irrespective of PresentMode for me, while screen blanking causes it only with PresentMode::Fifo.

@mdickopp
Copy link
Contributor Author

Does this also occur on the wgpu examples?

No, it does not. One of the wgpu examples does not run at all, indicating it needs a feature not supported by my hardware (Adapter does not support required features for this example: CONSERVATIVE_RASTERIZATION). All the other examples continue running when I activate screen blanking.

@mdickopp
Copy link
Contributor Author

I'm not very familiar with wgpu (or low-level graphics APIs, for that matter), so please take the following with a grain of salt.

I could track down the issue to this timeout in wgpu. If I modify it from 1 second to 10 seconds, the panic occurs only if I blank the screen for more than 10 seconds.

Taking a wild guess that treating a timeout like a changed surface instead of panicking might help, I tried this modification:

--- a/crates/bevy_render/src/view/window.rs
+++ b/crates/bevy_render/src/view/window.rs
@@ -152,7 +152,7 @@ pub fn prepare_windows(
 
         let frame = match surface.get_current_texture() {
             Ok(swap_chain_frame) => swap_chain_frame,
-            Err(wgpu::SurfaceError::Outdated) => {
+            Err(wgpu::SurfaceError::Outdated | wgpu::SurfaceError::Timeout) => {
                 render_device.configure_surface(surface, &swap_chain_descriptor);
                 surface
                     .get_current_texture()

With this change, the issue no longer occurs. (Even if this is not the correct fix, maybe it can provide hints to people with more expertise than me in this area.)

@mdickopp
Copy link
Contributor Author

Maybe the reason the issue does not occur with the wgpu examples is that they call surface.get_current_texture() only on Event::RedrawRequested, and the event is not generated while the screen is blanked?

@mdickopp
Copy link
Contributor Author

I can reproduce this bug on an Intel GPU as well.

2022-09-13T17:14:48.220831Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1.75    
2022-09-13T17:14:48.260219Z  INFO bevy_render::renderer: AdapterInfo { name: "Intel(R) HD Graphics 5500 (BDW GT2)", vendor: 32902, device: 5654, device_type: IntegratedGpu, backend: Vulkan }

@bors bors bot closed this as completed in ffa489a Nov 12, 2022
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fix bevyengine#3606
- Fix bevyengine#4579
- Fix bevyengine#3380

## Solution

When running on a Linux machine with some AMD or Intel device, when calling
`surface.get_current_texture()`, ignore `wgpu::SurfaceError::Timeout` errors.


## Alternative

An alternative solution found in the `wgpu` examples is:

```rust
let frame = surface
    .get_current_texture()
    .or_else(|_| {
        render_device.configure_surface(surface, &swap_chain_descriptor);
        surface.get_current_texture()
    })
    .expect("Error reconfiguring surface");
window.swap_chain_texture = Some(TextureView::from(frame));
```

See: <https://github.com/gfx-rs/wgpu/blob/94ce76391b560a66e36df1300bd684321e57511a/wgpu/examples/framework.rs#L362-L370>

Veloren [handles the Timeout error the way this PR proposes to handle it](gfx-rs/wgpu#1218 (comment)).

The reason I went with this PR's solution is that `configure_surface` seems to be quite an expensive operation, and it would run every frame with the wgpu framework solution, despite the fact it works perfectly fine without `configure_surface`.

I know this looks super hacky with the linux-specific line and the AMD check, but my understanding is that the `Timeout` occurrence is specific to a quirk of some AMD drivers on linux, and if otherwise met should be considered a bug.


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
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 O-Linux Specific to the Linux desktop operating system P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants