kvark / blade

Sharp and simple graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic when resizing window: `Result::unwrap()` on an `Err` value: ERROR_OUT_OF_DATE_KHR

ComputerDruid opened this issue · comments

I experienced this on Linux + KDE + X11 + nvidia-drivers.

Steps to reproduce:

  • checkout blade latest main (commit cda6127 )
  • cargo run --example particle
  • resize the window (sometimes one or two times)

Result:

thread 'main' panicked at blade-graphics/src/vulkan/init.rs:812:18:
called `Result::unwrap()` on an `Err` value: ERROR_OUT_OF_DATE_KHR
Backtrace
$ RUST_BACKTRACE=full cargo run --example particle
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s
     Running `target/debug/examples/particle`
thread 'main' panicked at blade-graphics/src/vulkan/init.rs:812:18:
called `Result::unwrap()` on an `Err` value: ERROR_OUT_OF_DATE_KHR
stack backtrace:
   0:     0x55bc4595ff16 - std::backtrace_rs::backtrace::libunwind::trace::h92ba5ac126ecc5ad
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x55bc4595ff16 - std::backtrace_rs::backtrace::trace_unsynchronized::hfaa118b6e3a8f31a
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55bc4595ff16 - std::sys_common::backtrace::_print_fmt::h2075f185adf13bbd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x55bc4595ff16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c4bd387f9f3f544
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55bc4598cc20 - core::fmt::rt::Argument::fmt::h018ecebdf268b5bb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/rt.rs:142:9
   5:     0x55bc4598cc20 - core::fmt::write::h938c332fdab924eb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/mod.rs:1120:17
   6:     0x55bc4595c22f - std::io::Write::write_fmt::h4a694b02e44e6363
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/io/mod.rs:1846:15
   7:     0x55bc4595fcf4 - std::sys_common::backtrace::_print::h3595c0f4303f3ccd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x55bc4595fcf4 - std::sys_common::backtrace::print::ha888e6736b0bc71f
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x55bc45961447 - std::panicking::default_hook::{{closure}}::he19a7f79f7beab5e
  10:     0x55bc459611a9 - std::panicking::default_hook::h67efe04e9a5d446e
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:292:9
  11:     0x55bc459618d8 - std::panicking::rust_panic_with_hook::h49021cdbc4b22349
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:781:13
  12:     0x55bc459617b2 - std::panicking::begin_panic_handler::{{closure}}::hfbf601f3d8c62d13
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:659:13
  13:     0x55bc45960416 - std::sys_common::backtrace::__rust_end_short_backtrace::h98dd020b6e913806
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:171:18
  14:     0x55bc45961504 - rust_begin_unwind
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:647:5
  15:     0x55bc44a26ef5 - core::panicking::panic_fmt::h0d3f1893e38be419
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/panicking.rs:72:14
  16:     0x55bc44a274d3 - core::result::unwrap_failed::h1356562ef8bc898c
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/result.rs:1649:5
  17:     0x55bc45688593 - core::result::Result<T,E>::unwrap::h1f61b8b556d39205
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/result.rs:1073:23
  18:     0x55bc45688593 - blade_graphics::hal::init::<impl blade_graphics::hal::Context>::acquire_frame::hf7a67c78629a41c0
                               at /tmp/blade/blade-graphics/src/vulkan/init.rs:809:13
  19:     0x55bc44aabfcd - particle::Example::render::h7b693e8427a0cf79
                               at /tmp/blade/examples/particle/main.rs:83:21
  20:     0x55bc44ab9644 - particle::main::{{closure}}::h21c28c2be8ab1f5d
                               at /tmp/blade/examples/particle/main.rs:202:29
  21:     0x55bc44ab8e8f - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hc55cbb9bfd64a8e0
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/ops/function.rs:294:13
  22:     0x55bc44ab8e2f - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h6744f2381e5fee92
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/ops/function.rs:294:13
  23:     0x55bc44aa4459 - winit::platform_impl::platform::x11::EventLoop<T>::single_iteration::hd9b875802e16b26e
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/x11/mod.rs:602:17
  24:     0x55bc44aa4cc5 - winit::platform_impl::platform::x11::EventLoop<T>::poll_events_with_timeout::h0559171b38495834
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/x11/mod.rs:541:9
  25:     0x55bc44aa280f - winit::platform_impl::platform::x11::EventLoop<T>::pump_events::hefa04aa07b9c4b37
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/x11/mod.rs:447:13
  26:     0x55bc44aa3065 - winit::platform_impl::platform::x11::EventLoop<T>::run_on_demand::hf4eb9ca22711f622
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/x11/mod.rs:408:19
  27:     0x55bc44ab80de - winit::platform_impl::platform::EventLoop<T>::run_on_demand::h815181939650123c
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/mod.rs:829:56
  28:     0x55bc44ab89e6 - winit::platform_impl::platform::EventLoop<T>::run::hf9d70478f409bc90
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/mod.rs:822:9
  29:     0x55bc44a95169 - winit::event_loop::EventLoop<T>::run::hb11f17c0697f4dad
                               at /home/cdruid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/event_loop.rs:249:9
  30:     0x55bc44aac80a - particle::main::h043935cd00e9f598
                               at /tmp/blade/examples/particle/main.rs:130:5
  31:     0x55bc44acbf4b - core::ops::function::FnOnce::call_once::hee517cd48cebcf88
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/ops/function.rs:250:5
  32:     0x55bc44a8f50e - std::sys_common::backtrace::__rust_begin_short_backtrace::h3f847eccec982308
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:155:18
  33:     0x55bc44a58941 - std::rt::lang_start::{{closure}}::h14c5f4be63ef514e
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/rt.rs:166:18
  34:     0x55bc45955dd1 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::he2501730d3d7649e
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/ops/function.rs:284:13
  35:     0x55bc45955dd1 - std::panicking::try::do_call::h900df580cee6b404
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:554:40
  36:     0x55bc45955dd1 - std::panicking::try::h2835d399792b43db
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:518:19
  37:     0x55bc45955dd1 - std::panic::catch_unwind::hdff7b6e6c35776df
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panic.rs:142:14
  38:     0x55bc45955dd1 - std::rt::lang_start_internal::{{closure}}::h6f12a67e0af11221
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/rt.rs:148:48
  39:     0x55bc45955dd1 - std::panicking::try::do_call::h226d8232820746bf
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:554:40
  40:     0x55bc45955dd1 - std::panicking::try::h7a70dd2f0620aaac
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:518:19
  41:     0x55bc45955dd1 - std::panic::catch_unwind::h4827d3381ec3b157
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panic.rs:142:14
  42:     0x55bc45955dd1 - std::rt::lang_start_internal::hc3f700406209db2c
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/rt.rs:148:20
  43:     0x55bc44a5891a - std::rt::lang_start::h3c69c0426c66f1ee
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/rt.rs:165:17
  44:     0x55bc44aac9de - main
  45:     0x7f602a41ec4a - <unknown>
  46:     0x7f602a41ed05 - __libc_start_main
  47:     0x55bc44a277d1 - _start
  48:                0x0 - <unknown>

I originally observed this on the Zed editor (reported downstream at zed-industries/zed#9628 ), but was able to reproduce it with just the particle example.

Some software versions in case that ends up being relevant:

blade $ git rev-parse HEAD
cda61274d271b70bc7174849266f0b344000aabf
$ kwin_x11 --version
kwin 5.27.10
$ nvidia-smi -q -u -x | xq -r .nvidia_smi_log.driver_version
545.29.06
$ echo $XDG_SESSION_TYPE 
x11
$ /usr/bin/X -version |& head -2
X.Org X Server 1.21.1.11

@ComputerDruid thank you for filing! The particle example doesn't really try to handle the resize. Are you able to reproduce this on the scene example in Blade? Also, are you able to get it on wgpu examples?
Finally, please attach the output of vulkaninfo as well as the full nvidia-smi output

No, I wasn't able to get the scene example to crash while resizing, which surprises me, since the panic didn't seem to be specifically in the example code.

nvidia-smi
$ nvidia-smi 
Sat Mar 30 22:17:21 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06              Driver Version: 545.29.06    CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 2070 ...    Off | 00000000:01:00.0  On |                  N/A |
| 30%   42C    P5              33W / 215W |    888MiB /  8192MiB |     32%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A       484      G   /usr/bin/X                                  352MiB |
|    0   N/A  N/A       715      G   /usr/bin/ksmserver                            2MiB |
|    0   N/A  N/A       717      G   /usr/bin/kded5                                2MiB |
|    0   N/A  N/A       718      G   /usr/bin/kwin_x11                            85MiB |
|    0   N/A  N/A       752      G   /usr/bin/plasmashell                         61MiB |
|    0   N/A  N/A       773      G   ...c/polkit-kde-authentication-agent-1        2MiB |
|    0   N/A  N/A       775      G   ...ib64/libexec/xdg-desktop-portal-kde        2MiB |
|    0   N/A  N/A       901      G   /usr/bin/kclockd                              2MiB |
|    0   N/A  N/A       903      G   /usr/lib64/libexec/kdeconnectd                2MiB |
|    0   N/A  N/A       918      G   /usr/bin/kaccess                              2MiB |
|    0   N/A  N/A       924      G   /usr/lib64/libexec/DiscoverNotifier           2MiB |
|    0   N/A  N/A      1187      G   ...erProcess --variations-seed-version       26MiB |
|    0   N/A  N/A      1401      G   /usr/bin/konsole                              2MiB |
|    0   N/A  N/A      1487      G   /usr/lib64/firefox/firefox                  328MiB |
+---------------------------------------------------------------------------------------+

vulkaninfo.txt

As for wgpu examples, none of the ones I tried panicked; I tried bunnymark, water, and skybox.

Blade's bunnymark example does crash when resized, though.

Interesting, thanks for all the info!
This might have something to do with our window-system-integration (WSI). If the Scene example works, then winit + Blade is fine. But if Zed doesn't work, something might be off in X11 support of Zed specifically.

This same issue also occurred with me when I was running GPUI on Windows.

It specifically happens when minimizing, maximizing and resizing.

How easy did this reproduce? Did the behavior change when zed-industries/zed#10243 landed?

The issue still seems to occur before that PR, a easy way to reproduce it for me is by resizing the window height so there is no height.
This causes the ERROR_OUT_OF_DATE_KHR doing this:
image

Minimizing and maximizing quickly also causes the error I think the error occurs specifically when the frame is being rerendered (not sure).