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

Bevy 0.5.0 can't run with DefaultPlugins: BackendSpecificError #2314

Closed
kugiyasan opened this issue Jun 7, 2021 · 16 comments
Closed

Bevy 0.5.0 can't run with DefaultPlugins: BackendSpecificError #2314

kugiyasan opened this issue Jun 7, 2021 · 16 comments
Labels
C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system

Comments

@kugiyasan
Copy link

Bevy version

bevy = "0.5.0"

Operating system & version

Arch Linux x86_64 5.10.42-1-lts
DE: KDE Plasma

What you did

cargo new cant_load_default_plugin
cd cant_load_default_plugin
printf 'use bevy::prelude::*;\nfn main() { App::build().add_plugins(DefaultPlugins).run(); }' > src/main.rs
echo 'bevy = "0.5.0"' >> Cargo.toml
cargo run

What you expected to happen

The program should build

What actually happened

5 compilation errors about use of unstable library feature

I then tried

rustup override set nightly
RUST_BACKTRACE=1 cargo run

but then

thread 'main' panicked at 'build_output_stream failed with all supported formats: BackendSpecific { err: BackendSpecificError { description: "ALSA function 'snd_pcm_start' failed with error 'EBADFD: File descriptor in bad state'" } }', $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:208:22
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/core/src/panicking.rs:92:14
   2: core::result::unwrap_failed
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/core/src/result.rs:1355:5
   3: core::result::Result<T,E>::expect
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/core/src/result.rs:997:23
   4: <cpal::platform::platform_impl::Device as rodio::stream::CpalDeviceExt>::try_new_output_stream::{{closure}}
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:204:17
   5: core::result::Result<T,E>::unwrap_or_else
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/core/src/result.rs:821:23
   6: <cpal::platform::platform_impl::Device as rodio::stream::CpalDeviceExt>::try_new_output_stream
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:200:12
   7: rodio::stream::OutputStream::try_from_device
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:31:32
   8: rodio::stream::OutputStream::try_default
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:45:9
   9: <bevy_audio::audio_output::AudioOutput<P> as core::default::Default>::default
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_audio-0.5.0/src/audio_output.rs:22:39
  10: <T as bevy_ecs::world::FromWorld>::from_world
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/world/mod.rs:928:9
  11: bevy_app::app_builder::AppBuilder::init_non_send_resource
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:272:28
  12: <bevy_audio::AudioPlugin as bevy_app::plugin::Plugin>::build
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_audio-0.5.0/src/lib.rs:23:9
  13: bevy_app::plugin_group::PluginGroupBuilder::finish
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/plugin_group.rs:104:21
  14: bevy_app::app_builder::AppBuilder::add_plugins
             at $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:295:9
  15: cant_load_default_plugin::main
             at ./src/main.rs:1:35
  16: core::ops::function::FnOnce::call_once
             at /rustc/dbe459dedd33470f2cb28101157de316caaffa66/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I also tried this src/main.rs, and this runs and exits instantly without any error, while I expected it to never exit

use bevy::prelude::*;
fn main() {
    App::build()
        .add_plugin(bevy::log::LogPlugin::default())
        .add_plugin(bevy::core::CorePlugin::default())
        .add_plugin(bevy::transform::TransformPlugin::default())
        .add_plugin(bevy::diagnostic::DiagnosticsPlugin::default())
        .add_plugin(bevy::input::InputPlugin::default())
        .add_plugin(bevy::window::WindowPlugin::default())
        .add_plugin(bevy::asset::AssetPlugin::default())
        .add_plugin(bevy::scene::ScenePlugin::default())
        .run();
}
@kugiyasan kugiyasan added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jun 7, 2021
@MinerSebas
Copy link
Contributor

MinerSebas commented Jun 7, 2021

5 compilation errors about use of unstable library feature

  1. Bevy requires the latest stable, that's the reason for your compilation errors

Nightly

  1. Seems like your ALSA install has problems: "ALSA function 'snd_pcm_start' failed with error 'EBADFD: File descriptor in bad state'"
    Did you take a look here? https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#arch--manjaro
    For now, you could disable the bevy_audio and mp3 Features to still compile

I also tried this src/main.rs, and this runs and exits instantly without any error, while I expected it to never exit

  1. Bevy needs a runner to drive the update loop/keep Bevy running, but you are missing WinitPlugin which provides it in Bevy.

@kugiyasan
Copy link
Author

Thanks for the quick answer!

  1. Yes, I was on the latest stable, but like I briefly said, I got 5 unstable features compilation errors, like the one below, and that's why I tried the nightly toolchain
rustup override set stable
cargo run
[...]
error[E0658]: use of unstable library feature 'unsafe_cell_get_mut'
   --> $HOME.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/storage/sparse_set.rs:217:32
    |
217 |         let ticks = self.ticks.get_mut().iter_mut();
    |                                ^^^^^^^
    |
    = note: see issue #76943 <https://github.com/rust-lang/rust/issues/76943> for more information

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `bevy_ecs`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
  1. I already looked at the dependencies, I reinstalled libx11 pkgconf alsa-lib, same results

@MinerSebas
Copy link
Contributor

Realy strange 🤔 , that Feature was stabilised in 1.50.0: rust-lang/rust#79485

@NathanSWard
Copy link
Contributor

What is your output from cargo --version and rustc --version?

@kugiyasan
Copy link
Author

Oops noob mistake, my stable was 1.49.0, I just had to rustup update. I somehow thought that rust would magically keep my stable always up to date...

$ cargo --version
cargo 1.52.0 (69767412a 2021-04-21)
$ rustc --version
rustc 1.52.1 (9bc8c42bb 2021-05-09)
For now, you could disable the `bevy_audio` and `mp3` Features to still compile

I still need to disable bevy_audio and mp3 to be able to run the program. It's not a problem for me, since I don't have intentions to touch the audio for now, but this still needs further investigation ig

@NathanSWard
Copy link
Contributor

@kugiyasan
Is it ok then if we close out this issue since your primary concern was solved?

@MinerSebas
Copy link
Contributor

#2269 also should have fixed that bevy panicks in your case. (Though you will still be missing audio)

@Pomegranate123
Copy link

Pomegranate123 commented Jun 15, 2021

I'm having the exact same problem, I was going through the Bevy book and as soon as I added .add_plugins(DefaultPlugins) I got the same error:

$ cargo r
    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/game`
thread 'main' panicked at 'build_output_stream failed with all supported formats: BackendSpecific { err: BackendSpecificError { description: "ALSA function \'snd_pcm_start\' failed with error \'EBADFD: File descriptor in bad state\'" } }', /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:208:22
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/option.rs:1329:5
   3: core::result::Result<T,E>::expect
             at /home/pomegranate/.config/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:997:23
   4: <cpal::platform::platform_impl::Device as rodio::stream::CpalDeviceExt>::try_new_output_stream::{{closure}}
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:204:17
   5: core::result::Result<T,E>::unwrap_or_else
             at /home/pomegranate/.config/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:821:23
   6: <cpal::platform::platform_impl::Device as rodio::stream::CpalDeviceExt>::try_new_output_stream
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:200:12
   7: rodio::stream::OutputStream::try_from_device
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:31:32
   8: rodio::stream::OutputStream::try_default
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/rodio-0.13.1/src/stream.rs:45:9
   9: <bevy_audio::audio_output::AudioOutput<P> as core::default::Default>::default
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_audio-0.5.0/src/audio_output.rs:22:39
  10: <T as bevy_ecs::world::FromWorld>::from_world
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.5.0/src/world/mod.rs:928:9
  11: bevy_app::app_builder::AppBuilder::init_non_send_resource
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:272:28
  12: <bevy_audio::AudioPlugin as bevy_app::plugin::Plugin>::build
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_audio-0.5.0/src/lib.rs:23:9
  13: bevy_app::plugin_group::PluginGroupBuilder::finish
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/plugin_group.rs:104:21
  14: bevy_app::app_builder::AppBuilder::add_plugins
             at /home/pomegranate/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.5.0/src/app_builder.rs:295:9
  15: game::main
             at ./src/main.rs:8:5
  16: core::ops::function::FnOnce::call_once
             at /home/pomegranate/.config/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Versions:

$ cargo --version
cargo 1.52.0-nightly (90691f2bf 2021-03-16)
$ rustc --version
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
$ uname -rm
5.12.2-arch1-1 x86_64

Cargo.toml:

$ cat Cargo.toml
[package]
name = "game"
version = "0.1.0"
authors = ["Pomegranate123 <#####@#####.####>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "0.5.0", features = ["dynamic"] }

I reinstalled the necessary dependencies for Arch, but nothing changed. Removing the dynamic feature also didn't work.

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 15, 2021

ALSA function 'snd_pcm_start' failed with error 'EBADFD: File descriptor in bad state'

This is a problem with initializing the sound plugin. Since #2269 this no longer causes a crash. Just missing sound.

@Pomegranate123
Copy link

What do you mean with 'no longer causes a crash'? My code isn't compiling because of it, isn't that a crash? What would I need to do to fix it?

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 15, 2021

Your code does compile. It just crashed when actually running it due to failed initialization of the sound plugin. The fix would be to either disable the sound plugin (.add_plugins_with(DefaultPlugins, |plugins| plugins.disable::<bevy::audio::AudioPlugin>())) or switch to the main branch.

@Pomegranate123
Copy link

Alright, but what if I do want to use sound? Is anything known about the actual issue yet, workaround aside?

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 15, 2021

Not that I know. Some people have this issue, most don't so it is hard to reproduce.

@kugiyasan
Copy link
Author

@Pomegranate123 I finally found a fix! I tried a bunch of things, and I discovered that I couldn't play sound with ALSA. Test your ALSA with aplay -v a_random_sound.wav. If you don't hear any sound, make sure the printed output device matches the one you're using. Mine didn't match, so I changed my default alsa output device like explained here, and boom, bevy audio worked!

@lafi-99

This comment was marked as spam.

@Pomegranate123
Copy link

@Pomegranate123 I finally found a fix! I tried a bunch of things, and I discovered that I couldn't play sound with ALSA. Test your ALSA with aplay -v a_random_sound.wav. If you don't hear any sound, make sure the printed output device matches the one you're using. Mine didn't match, so I changed my default alsa output device like explained here, and boom, bevy audio worked!

Sadly didn't work. I was already using the correct device and could play audio fine. The only issue is when I try to use bevy. I'm also using pulseaudio, if that changes anything.

@alice-i-cecile alice-i-cecile added O-Linux Specific to the Linux desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Jul 8, 2021
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 O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

No branches or pull requests

7 participants