bevyengine / bevy

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

Crash due to wgpu during startup on Wayland #14494

Open umut-sahin opened 1 month ago

umut-sahin commented 1 month ago

Bevy version

v0.14.0

Relevant system information

What you did

App::new().add_plugins(DefaultPlugins).run()

What went wrong

2024-07-26T21:40:39.730796Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
    setup_loader_term_phys_devs:  Failed to detect any valid GPUs in the current config    
2024-07-26T21:40:39.730807Z ERROR wgpu_hal::vulkan::instance:     objects: (type: INSTANCE, hndl: 0x5d5f80d8b9d0, name: ?)    
2024-07-26T21:40:39.730810Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of an object has failed    
2024-07-26T21:40:39.731380Z  INFO bevy_render::renderer: AdapterInfo { name: "NV172", vendor: 65541, device: 0, device_type: Other, driver: "OpenGL", driver_info: "4.3 (Compatibility Profile) Mesa 24.1.4-arch1.2", backend: Gl }
2024-07-26T21:40:39.780780Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
2024-07-26T21:40:39.780925Z  INFO bevy_winit::system: Creating new window "App" (Entity { index: 0, generation: 1 })
2024-07-26T21:40:39.781217Z  INFO winit::platform_impl::linux::x11::window: Guessed window scale factor: 1
2024-07-26T21:40:39.791330Z ERROR wgpu_core::device::global: surface configuration failed: incompatible window kind    

Additional information

     description: VGA compatible controller
       product: GA102 [GeForce RTX 3080 Ti]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: /dev/fb0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=nouveau latency=0 mode=2560x1440 resolution=2560,1440 visual=truecolor xres=2560 yres=1440
       resources: iomemory:400-3ff iomemory:440-43f irq:243 memory:84000000-84ffffff memory:4000000000-43ffffffff memory:4400000000-4401ffffff ioport:5000(size=128) memory:85000000-8507ffff

Let me know if anything else is needed!

Friz64 commented 1 month ago

Looks like winit is using the X11 backend. Maybe something with XWayland is broken on your machine. What happens when you enable bevy's wayland feature?

umut-sahin commented 1 month ago

I'll try it and get back to you in a week or so, I'm away from my desktop ATM.

But even if it solves the issue, that would mean I need to provide two binaries for Linux distribution which is not ideal.

Friz64 commented 1 month ago

That's not how that works. You can have both features enabled. Bevy will prefer Wayland but seamlessly fall back to X11 as needed.

umut-sahin commented 1 month ago

Oh, okay I'll try and let you know then.

Btw, why isn't it enabled by default then?

Friz64 commented 1 month ago

Because there has historically always been some kind of problem on Wayland affecting a portion of users. Sometimes it's our fault (https://github.com/gfx-rs/wgpu/issues/5505), sometimes not (https://github.com/gfx-rs/wgpu/issues/4775). On the other hand though, there have also been issues that were solved by turning the Wayland feature on (maybe yours is one of those), so it's hard to say.

I will personally try to push for Wayland-By-Default once https://github.com/gfx-rs/wgpu/issues/5505 gets resolved. Hopefully nothing else "major" crops up until then.

umut-sahin commented 1 month ago

Enabling wayland feature just changed the error:

2024-08-08T08:55:42.974400Z ERROR wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
    setup_loader_term_phys_devs:  Failed to detect any valid GPUs in the current config    
2024-08-08T08:55:42.974410Z ERROR wgpu_hal::vulkan::instance:   objects: (type: INSTANCE, hndl: 0x5aba20682820, name: ?)    
2024-08-08T08:55:42.974414Z ERROR wgpu_hal::vulkan::instance: enumerate_adapters: Initialization of an object has failed    
2024-08-08T08:55:42.975153Z  INFO bevy_render::renderer: AdapterInfo { name: "NV172", vendor: 65541, device: 0, device_type: Other, driver: "OpenGL", driver_info: "4.3 (Compatibility Profile) Mesa 24.1.5-arch1.1", backend: Gl }
2024-08-08T08:55:43.025122Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
2024-08-08T08:55:43.025265Z  INFO bevy_winit::system: Creating new window "Mythmallow" (Entity { index: 0, generation: 1 })
2024-08-08T08:55:43.070426Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (11)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::create_surfaces`!
2024-08-08T08:55:43.070666Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (11)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::render_asset::prepare_assets<bevy_render::texture::image::GpuImage>`!
2024-08-08T08:55:43.070723Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (11)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::render_asset::prepare_assets<bevy_sprite::mesh2d::material::PreparedMaterial2d<bevy_sprite::mesh2d::color_material::ColorMaterial>>`!
2024-08-08T08:55:43.070801Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'main' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::render_asset::prepare_assets<bevy_pbr::material::PreparedMaterial<bevy_pbr::pbr_material::StandardMaterial>>`!
2024-08-08T08:55:43.071019Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (9)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::globals::prepare_globals_buffer`!
2024-08-08T08:55:43.071082Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (10)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_pbr::render::skin::prepare_skins`!
2024-08-08T08:55:43.071225Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (10)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::view::visibility::range::write_render_visibility_ranges`!
2024-08-08T08:55:43.071298Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread 'Compute Task Pool (7)' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_sprite::render::prepare_sprite_image_bind_groups`!
2024-08-08T08:55:43.071459Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent    
thread '<unnamed>' panicked at /home/default/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/egl.rs:296:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::renderer::render_system`!
Friz64 commented 1 month ago

Ohh you don't have a Vulkan driver. Native Wayland is currently broken on OpenGL (as linked in my previous comment). You might want to install NVK given you're not using the proprietary drivers?

umut-sahin commented 1 month ago

Installing the driver fixed the issue :partying_face:

Though if there is a way to improve the error messages, they should be improved IMO. Like detecting OpenGL is being tried to be used in Wayland and logging an error saying it's not supported.

Thanks!