bevyengine / bevy

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

REGRESSION: wgpu panic `BadDisplay` after winit 0.30 on Wayland OpenGL #13923

Open inodentry opened 2 weeks ago

inodentry commented 2 weeks ago

Bevy version

I first found the bug when trying the 0.14 release candidates. I ran a git bisect and tracked down the problem to the commit which updated bevy to use winit 0.30. So all Bevy versions that are based on winit 0.30 are affected.

Bevy 0.13.x (and commits before the winit 0.30 update) are not affected.

Relevant system information

SystemInfo { os: "Linux 39 Fedora Linux Asahi Remix", kernel: "6.8.10-400.asahi.fc39.aarch64+16k", cpu: "Icestorm-M1-Pro", core_count: "10", memory: "30.9 GiB" }
AdapterInfo { name: "Apple M1 Pro (G13S C0)", vendor: 65541, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }

Asahi does not have a GPU Vulkan driver yet (though probably will soon…) and this bug makes Bevy unusable.

What you did

Run any bevy app or example.

You need --features wayland and WGPU_BACKEND=gl to run Bevy on Asahi. Bevy chooses CPU Vulkan over OpenGL by default for some reason, and X11 with Gl backend does not work.

WGPU_BACKEND=gl cargo run --features wayland --example 3d_scene

What went wrong

Bevy immediately crashes with various systems in the Render schedule panicking. The panic comes from wgpu unwrapping a BadDisplay error related to calling eglMakeCurrent. Something must be going wrong with how winit and wgpu interact in Bevy.

2024-06-19T11:15:27.791229Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (1)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295: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-06-19T11:15:27.794062Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'main' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295: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-06-19T11:15:27.794372Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (0)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_pbr::render::light::prepare_lights`!
2024-06-19T11:15:27.794516Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (1)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295: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-06-19T11:15:27.794976Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (2)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295: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-06-19T11:15:27.795235Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (1)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::render_asset::prepare_assets<bevy_render::mesh::mesh::GpuMesh>`!
2024-06-19T11:15:27.795881Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'main' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::view::prepare_view_uniforms`!
2024-06-19T11:15:27.795956Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (0)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::globals::prepare_globals_buffer`!
2024-06-19T11:15:27.796070Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'main' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_pbr::render::skin::prepare_skins`!
2024-06-19T11:15:27.796160Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (1)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
2024-06-19T11:15:27.796272Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'main' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_pbr::render::fog::prepare_fog`!
Encountered a panic in system `bevy_pbr::ssr::prepare_ssr_settings`!
2024-06-19T11:15:27.796741Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'main' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_pbr::cluster::prepare_clusters`!
2024-06-19T11:15:27.796812Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (0)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
2024-06-19T11:15:27.798305Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (1)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_core_pipeline::core_3d::prepare_core_3d_depth_textures`!
2024-06-19T11:15:27.799596Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (3)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
Encountered a panic in system `bevy_pbr::light_probe::upload_light_probes`!
called `Result::unwrap()` on an `Err` value: BadDisplay
2024-06-19T11:15:27.800186Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (2)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::view::visibility::range::write_render_visibility_ranges`!
Encountered a panic in system `bevy_render::batching::gpu_preprocessing::write_batched_instance_buffers<bevy_pbr::render::mesh::MeshPipeline>`!
2024-06-19T11:15:27.800911Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread 'Compute Task Pool (3)' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_sprite::render::prepare_sprite_image_bind_groups`!
2024-06-19T11:15:27.802199Z ERROR wgpu_hal::gles::egl: EGL 'eglMakeCurrent' code 0x3008: eglMakeCurrent
thread '<unnamed>' panicked at /home/iyes/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.19.4/src/gles/egl.rs:295:14:
called `Result::unwrap()` on an `Err` value: BadDisplay
Encountered a panic in system `bevy_render::renderer::render_system`!

Additional Information

winit 0.30.2 is broken on aarch64 and does not compile. winit 0.30.0, 0.30.1, and git main, compile successfully. You have to force cargo to use one of those versions, in order to compile bevy successfully and to reproduce this bug.

Friz64 commented 2 weeks ago

FWIW I can reproduce this exact same behavior on x86. This is https://github.com/gfx-rs/wgpu/issues/5505.