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

examples/app/headless.rs implies presence of non-existent feature #464

Closed
ndarilek opened this issue Sep 9, 2020 · 3 comments · Fixed by #502
Closed

examples/app/headless.rs implies presence of non-existent feature #464

ndarilek opened this issue Sep 9, 2020 · 3 comments · Fixed by #502
Labels
C-Bug An unexpected or incorrect behavior C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples

Comments

@ndarilek
Copy link
Contributor

ndarilek commented Sep 9, 2020

// This example disables the default plugins by not registering them during setup.
// You can also completely remove rendering / windowing Plugin code from bevy
// by making your import look like this in your Cargo.toml
//
// [dependencies]
// bevy = { version = "0.1.3", default-features = false, features = ["headless"] }

Building with that feature doesn't work and claims it doesn't exist. Not sure if the comment should go or if the feature should materialize. :)

Thanks.

@memoryruins memoryruins added C-Bug An unexpected or incorrect behavior C-Examples An addition or correction to our examples C-Docs An addition or correction to our documentation labels Sep 9, 2020
@memoryruins
Copy link
Contributor

The fix for this may be to remove that feature from the example's comments and leave it as

// [dependencies]
// bevy = { version = "0.1.3", default-features = false }

since disabling the default features essentially makes it headless.
https://github.com/bevyengine/bevy/blob/master/docs/cargo_features.md

@ndarilek
Copy link
Contributor Author

Unfortunately not. If I do, then initialize:

    App::build()
        .add_default_plugins()
        .add_resource(terminal)
        .add_system(render_system.system())
        .run();

I get:

thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'Resource does no
t exist alloc::boxed::Box<dyn bevy_render::renderer::render_resource_context::Re
nderResourceContext>Resource does not exist alloc::boxed::Box<dyn bevy_render::r
enderer::render_resource_context::RenderResourceContext>', ', C:\Users\Nolan Dar
ilek\scoop\persist\rustup\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/r
ustlib/src/rust\src\libstd\macros.rsC:\Users\Nolan Darilek\scoop\persist\rustup\
.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\src\libstd
\macros.rs::1616::99

Here, render_system is a function that calls terminal-rendering functions. It shouldn't trigger this failure, and doesn't if I initialize a plugin subset.

I did have this working if I initialized a subset of plugins, namely just the scheduler, but a feature or disabling defaults would certainly be nice.

Thanks.

@memoryruins
Copy link
Contributor

Good point, I did not try it with add_default_plugins earlier. #485 recently added a render feature that makes the entire render pipeline optional. With default-features disabled, It now runs on master branch without a panic.

[dependencies.bevy]
git = "https://github.com/bevyengine/bevy"
rev = "b9f549efaac3215e63a2d2022d58f58648adf8cb"
default-features = false
use std::time::Duration;
use bevy::{app::ScheduleRunnerPlugin, prelude::*};

struct SystemTimer(Timer);

fn a(time: Res<Time>, mut timer: ResMut<SystemTimer>) {
    timer.0.tick(time.delta_seconds);
    if timer.0.finished {
        println!("-");
        timer.0.reset();
    }
}

fn main() {
    let wait_duration = Duration::from_secs_f64(1.0 / 60.0);
    App::build()
        .add_plugin(ScheduleRunnerPlugin::run_loop(wait_duration))
        .add_resource(SystemTimer(Timer::from_seconds(1.0, true)))
        .add_system(a.system())
        .add_default_plugins()
        .run();
}
   Compiling bevy_ui_tools v0.1.0
    Finished dev [optimized + debuginfo] target(s) in 1.29s
     Running `target\debug\bevy_ui_tools.exe`
-
-
-
-
-

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 C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants