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

segfault on WSL2 using the WgpuPlugin #2922

Closed
bacongobbler opened this issue Oct 6, 2021 · 4 comments
Closed

segfault on WSL2 using the WgpuPlugin #2922

bacongobbler opened this issue Oct 6, 2021 · 4 comments
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@bacongobbler
Copy link

Bevy version

bevy = "0.5"
bevy_wgpu = "0.5"

Operating system & version

Windows 11, running WSL2 with WSLg enabled

What you did

Given the following main.rs:

use bevy::prelude::*;
use bevy_wgpu::WgpuPlugin;

fn main() {
    App::build()
        .add_plugin(WgpuPlugin)
        .run();
}

Execution returns a segmentation fault:

><> RUST_LOG=debug cargo run
   Compiling test-bevy-segfault v0.1.0 (/home/bacongobbler/code/test-bevy-segfault)
    Finished dev [unoptimized + debuginfo] target(s) in 6.46s
     Running `target/debug/test-bevy-segfault`
Segmentation fault

If you change it to using all of the default plugins:

use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugin(DefaultPlugins)
        .run();
}

A little more information is provided:

><> RUST_LOG=debug cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/test-bevy-segfault`
Oct 06 08:07:08.318 DEBUG bevy_app::plugin_group: added plugin: bevy_core::CorePlugin
Oct 06 08:07:08.320 DEBUG bevy_app::plugin_group: added plugin: bevy_transform::TransformPlugin
Oct 06 08:07:08.320 DEBUG bevy_app::plugin_group: added plugin: bevy_diagnostic::DiagnosticsPlugin
Oct 06 08:07:08.320 DEBUG bevy_app::plugin_group: added plugin: bevy_input::InputPlugin
Oct 06 08:07:08.320 DEBUG bevy_app::plugin_group: added plugin: bevy_window::WindowPlugin
Oct 06 08:07:08.321 DEBUG bevy_app::plugin_group: added plugin: bevy_asset::AssetPlugin
Oct 06 08:07:08.321 DEBUG bevy_app::plugin_group: added plugin: bevy_scene::ScenePlugin
Oct 06 08:07:08.321 DEBUG bevy_app::plugin_group: added plugin: bevy_render::RenderPlugin
Oct 06 08:07:08.322 DEBUG bevy_app::plugin_group: added plugin: bevy_sprite::SpritePlugin
Oct 06 08:07:08.323 DEBUG bevy_app::plugin_group: added plugin: bevy_pbr::PbrPlugin
Oct 06 08:07:08.323 DEBUG bevy_app::plugin_group: added plugin: bevy_ui::UiPlugin
Oct 06 08:07:08.324 DEBUG bevy_app::plugin_group: added plugin: bevy_text::TextPlugin
Oct 06 08:07:08.324 DEBUG bevy_app::plugin_group: added plugin: bevy_audio::AudioPlugin
Oct 06 08:07:08.330 DEBUG bevy_app::plugin_group: added plugin: bevy_gilrs::GilrsPlugin
Oct 06 08:07:08.360 DEBUG bevy_app::plugin_group: added plugin: bevy_gltf::GltfPlugin
Oct 06 08:07:08.360 DEBUG bevy_app::plugin_group: added plugin: bevy_winit::WinitPlugin
Oct 06 08:07:08.360 DEBUG bevy_app::plugin_group: added plugin: bevy_wgpu::WgpuPlugin
Segmentation fault

What you expected to happen

A more informative error message explaining why the WgpuPlugin failed to initialize would be great. Having a working WgpuPlugin system on WSLg would be even better!

What actually happened

Segmentation fault.

Additional information

Example app can be found here: https://github.com/bacongobbler/bevy-wgpu-segfault-test

@bacongobbler bacongobbler added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 6, 2021
@bacongobbler
Copy link
Author

Note that this may be related to #2661, as @kacystocks suggests his example segfaults when adding the DefaultPlugins to his project.

@DJMcNab
Copy link
Member

DJMcNab commented Oct 6, 2021

I assume that wgpu doesn't support wslg yet, or at least not in 0.8/0.9 which we use

Have you tried a wgpu example (both 0.8 and the latest main)? If neither of those segfault, it's our problem. If only the former fails, all is good, and if the latter fails too, it would be a wgpu issue.

@bacongobbler
Copy link
Author

I also managed to reproduce the same issue on main by cloning bevy and calling cargo run --example breakout.

><> RUST_LOG=debug cargo run --example breakout
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/examples/breakout`
Oct 06 08:27:19.547 DEBUG bevy_app::plugin_group: added plugin: bevy_core::CorePlugin
Oct 06 08:27:19.549 DEBUG bevy_app::plugin_group: added plugin: bevy_transform::TransformPlugin
Oct 06 08:27:19.549 DEBUG bevy_app::plugin_group: added plugin: bevy_diagnostic::DiagnosticsPlugin
Oct 06 08:27:19.549 DEBUG bevy_app::plugin_group: added plugin: bevy_input::InputPlugin
Oct 06 08:27:19.549 DEBUG bevy_app::plugin_group: added plugin: bevy_window::WindowPlugin
Oct 06 08:27:19.550 DEBUG bevy_app::plugin_group: added plugin: bevy_asset::AssetPlugin
Oct 06 08:27:19.550 DEBUG bevy_app::plugin_group: added plugin: bevy_scene::ScenePlugin
Oct 06 08:27:19.550 DEBUG bevy_app::plugin_group: added plugin: bevy_render::RenderPlugin
Oct 06 08:27:19.551 DEBUG bevy_app::plugin_group: added plugin: bevy_sprite::SpritePlugin
Oct 06 08:27:19.552 DEBUG bevy_app::plugin_group: added plugin: bevy_pbr::PbrPlugin
Oct 06 08:27:19.552 DEBUG bevy_app::plugin_group: added plugin: bevy_ui::UiPlugin
Oct 06 08:27:19.553 DEBUG bevy_app::plugin_group: added plugin: bevy_text::TextPlugin
Oct 06 08:27:19.553 DEBUG bevy_app::plugin_group: added plugin: bevy_audio::AudioPlugin
Oct 06 08:27:19.558 DEBUG bevy_app::plugin_group: added plugin: bevy_gilrs::GilrsPlugin
Oct 06 08:27:19.588 DEBUG bevy_app::plugin_group: added plugin: bevy_gltf::GltfPlugin
Oct 06 08:27:19.589 DEBUG bevy_app::plugin_group: added plugin: bevy_winit::WinitPlugin
Oct 06 08:27:19.589 DEBUG bevy_app::plugin_group: added plugin: bevy_wgpu::WgpuPlugin
Segmentation fault

Have you tried a wgpu example (both 0.8 and the latest main)?

Not yet, but I was just about to! I will report back with any findings. If I manage to nail it down to a wgpu issue I'll open a ticket there and report back.

@bacongobbler
Copy link
Author

Yep. Looks like WSLg support is unavailable at this time. It looks like D3D12 support (rather, DirectX 12 support on Linux) is required before wgpu-rs can work as per gfx-rs/wgpu#1443 and https://github.com/microsoft/wslg#opengl-accelerated-rendering-in-wslg

><> export WGPU_BACKEND=gl
><> cargo run --example cube
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `/home/bacongobbler/code/wgpu/target/debug/examples/cube`
[2021-10-06T15:44:42Z ERROR smithay_client_toolkit::window::concept_frame] No font could be found
thread 'main' panicked at 'No suitable GPU adapters found on the system!', wgpu/examples/cube/../framework.rs:124:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm going to close this as an upstream issue. I'd suggest closing #2661 as well if you can nail it down to gfx-rs/wgpu#1443.

Thanks for the pointer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

2 participants