bevyengine / bevyengine/bevy

MinimalPlugins + Window requires additional plugins (RenderPlugin)

Open
#21,900 0 comments 0 reactions 0 assignees View on GitHub
A-Windowing C-Docs D-Straightforward S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

Running Bevy 0.17.2 on Ubuntu 24.04.3 LTS with wayland

Was trying to run a minimal bevy app to get the maximum FPS of windowed vs headless when using MinimalPlugins.

According to:

https://docs.rs/bevy/latest/bevy/winit/struct.WinitPlugin.html

"When using eg. MinimalPlugins you can add this using `WinitPlugin::::default()`, where WakeUp is the default event that bevy uses."

I had the following code:

```rust

use bevy::prelude::*;

fn main() {
let mut app = App::new();
app.add_plugins(MinimalPlugins);

#[cfg(feature = "window")]
{
use bevy::window::PresentMode;
use bevy::winit::{UpdateMode, WakeUp, WinitPlugin, WinitSettings};

app.add_plugins(WindowPlugin {
primary_window: Some(Window {
present_mode: PresentMode::Mailbox,
..default()
}),
..default()
})
.add_plugins(WinitPlugin::::default())
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
});
}

app.run();
}
```

With Cargo.toml (running with default features and profile):

```
[package]
name = "bevy_example"
version = "0.1.0"
edition = "2021"

[features]
default = ["window", "debug"]
debug = ["bevy/debug"]
window = ["bevy/bevy_winit", "bevy/wayland", "bevy/x11"]

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

[profile.dev]
opt-level = 0
debug = 0
debug-assertions = true
overflow-checks = false
incremental = true
lto = false

[profile.release]
opt-level = 3
lto = "thin"
debug = false
```

And it crashed with:

```
thread 'main' (20503) panicked at /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.17.3/src/system/system_param.rs:813:21:
Resource requested by (bevy_ecs::system::commands::Commands<'_, '_>, bevy_ecs::system::query::Query<'_, '_, (bevy_ecs::entity::Entity, &mut bevy_window::window::Window, &bevy_window::window::CursorOptions, core::option::Option<&bevy_window::raw_handle::RawHandleWrapperHolder>), bevy_ecs::query::filter::Added>, bevy_ecs::message::message_writer::MessageWriter<'_, bevy_window::event::WindowCreated>, bevy_ecs::change_detection::ResMut<'_, bevy_winit::accessibility::WinitActionRequestHandlers>, bevy_ecs::change_detection::Res<'_, bevy_a11y::AccessibilityRequested>, bevy_ecs::change_detection::Res<'_, bevy_winit::winit_monitors::WinitMonitors>) does not exist: bevy_a11y::AccessibilityRequested
```

Adding the bevy::a11y::AccessibilityPlugin changed the error to:

```
thread 'main' (20768) panicked at /home/martin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.17.3/src/error/handler.rs:125:1:
Encountered an error in system `bevy_winit::system::check_keyboard_focus_lost`: Parameter `MessageWriter<'_, KeyboardFocusLost>::messages` failed validation: Message not initialized
If this is an expected state, wrap the parameter in `Option` and handle `None` when it happens, or wrap the parameter in `If` to skip the system when it happens.
1: >::from
3: bevy_ecs::system::system::System::run_without_applying_deferred
note: Some "noisy" backtrace lines have been filtered out. Run with `BEVY_BACKTRACE=full` for a verbose backtrace.
```

Adding the bevy::input::InputPlugin made it run but without opening a window.

I then had to painstakingly enable/disable plugins inside DefaultPlugins until I discovered that the RenderPlugin (and all of the plugins it depends on) need to be enabled for a window to be opened.

Perhaps I was not looking in the right places, but I would say it isn't clear that disabling default features effectively makes DefaultPlugins act like MinimalPlugins (for the most part).

It would be nice if the official examples contained a default-features disabled example of a minimal app that can be toggled between headless and windowed mode that runs at max FPS, perhaps just a stress test of max FPS with an empty window with or without a renderer. When I disabled the Wgpu settings backend the window stopped opening.

This was for the specific use case of running a simulator within bevy as fast as possible without it being bottle necked by the renderer.

A couple of relevant issues I saw that solved this using a schedule:
https://github.com/bevyengine/bevy/discussions/8539
https://github.com/bevyengine/bevy/discussions/6648

No real "issue" here, just documentation improvement and perhaps this post can save time for someone running into the same situation.

Contributor guide

Open the contributing guide

Research direction

Start with the WinitPlugin documentation and the MinimalPlugins, WindowPlugin, InputPlugin, AccessibilityPlugin, and RenderPlugin entry points described in the issue. Add an official default-features-disabled example that can run headless or open an empty window, documents the required plugins, and demonstrates the intended high-FPS setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.