wgpu: X11 error: BadDrawable/BadMatch
Description The example with the triangle crashes.
Repro steps
If I run RUST_BACKTRACE=1 cargo run --example hello-triangle
I have this error.
[2023-03-04T15:31:54Z ERROR winit::platform_impl::platform] X11 error: XError {
description: "BadDrawable (invalid Pixmap or Window parameter)",
error_code: 9,
request_code: 149,
minor_code: 4,
}
thread 'main' panicked at 'Failed to focus input context: XError { description: "BadDrawable (invalid Pixmap or Window parameter)", error_code: 9, request_code: 149, minor_code: 4 }', /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/event_processor.rs:912:30
stack backtrace:
0: rust_begin_unwind
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
2: core::result::unwrap_failed
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/result.rs:1791:5
3: core::result::Result<T,E>::expect
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/result.rs:1070:23
4: winit::platform_impl::platform::x11::event_processor::EventProcessor<T>::process_event
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/event_processor.rs:909:25
5: winit::platform_impl::platform::x11::EventLoop<T>::drain_events
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:517:13
6: winit::platform_impl::platform::x11::EventLoop<T>::run_return::single_iteration
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:348:13
7: winit::platform_impl::platform::x11::EventLoop<T>::run_return
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:448:31
8: winit::platform_impl::platform::x11::EventLoop<T>::run
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/x11/mod.rs:503:25
9: winit::platform_impl::platform::EventLoop<T>::run
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/mod.rs:755:56
10: winit::event_loop::EventLoop<T>::run
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/event_loop.rs:278:9
11: hello_triangle::run::{{closure}}
at ./wgpu/examples/hello-triangle/main.rs:85:5
12: pollster::block_on
at /home/dapx/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.5/src/lib.rs:125:15
13: hello_triangle::main
at ./wgpu/examples/hello-triangle/main.rs:149:9
14: core::ops::function::FnOnce::call_once
at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Platform
Information about your OS, version of wgpu
, your tech stack, etc.
I am using webgpu 0.15.0, I have just cloned the repo.
My uname -r -a
output is: Linux pop-os 6.1.11-76060111-generic #202302091138~1675975749~22.04~f771a7f SMP PREEMPT_DYNAMIC Thu F x86_64 x86_64 x86_64 GNU/Linux
The output of sudo lshw -c video
is:
*-display
description: VGA compatible controller
product: TU106M [GeForce RTX 2060 Max-Q]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:01:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
configuration: driver=nvidia latency=0
resources: irq:102 memory:fb000000-fbffffff memory:b0000000-bfffffff memory:c0000000-c1ffffff ioport:f000(size=128) memory:fc000000-fc07ffff
*-display
description: VGA compatible controller
product: Renoir
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:04:00.0
logical name: /dev/fb0
version: c6
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi msix vga_controller bus_master cap_list fb
configuration: depth=32 driver=amdgpu latency=0 resolution=1920,1080
resources: irq:47 memory:d0000000-dfffffff memory:e0000000-e01fffff ioport:e000(size=256) memory:fc500000-fc57ffff
I have already reported the issue to the winit developers, but it looks like it’s not a winit problem https://github.com/rust-windowing/winit/issues/2716.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 18 (6 by maintainers)
Just to add another data point: I am running into the same issue. I have a CPU with integrated GPU and a dedicated GPU. The desktop is running on the dedicated one, but wgpu chose the integrated GPU, which is the cause of the problem. For me the error happens when calling
winit::Window::inner_size
, actually. It eventually callswinit::platform_impl::platform::x11::window::UnownedWindow::inner_size_physical
which then incorrectly callsunwrap
.I’m using
wgpu::PowerPreference::default()
which defaults to the low power GPU. Even withWGPU_POWER_PREF=high
, the integrated GPU was chosen. Withwgpu::PowerPreference::HighPerformance
, the dedicated one was chosen and everything works.In my
RequestAdapterOptions
I’m also of course specifyingcompatible_surface
. So my guess is that the “adapter choosing” code does not correctly checkcompatible_surface
because the integrated GPU should be incompatible with the surface I passed.@teoxoy maybe it makes sense to change the title from BadDrawable to BadMatch? just inc ase other users have the same problem.