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

fix: removed WinitPlugin from headless_renderer example #15818

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cxreiff
Copy link

@cxreiff cxreiff commented Oct 10, 2024

Objective

The headless_renderer example is meant to showcase running bevy as a headless renderer, but if run without a display server (for example, over an SSH connection), a panic occurs in bevy_winit despite never creating a window:

bevy_winit-0.14.1/src/lib.rs:132:14:
winit-0.30.5/src/platform_impl/linux/mod.rs:
neither WAYLAND_DISPLAY nor WAYLAND_SOCKET nor DISPLAY is set.

This example should run successfully in situations without an available display server, as although the GPU is used for rendering, no window is ever created.

Solution

Disabling WinitPlugin, where the above panic occurs, allows the example to run in a fully headless environment.

Testing

  • I tested this change in normal circumstances with a display server (on macOS Sequoia and Asahi Linux) and behavior was normal.
  • I tested with no display server by connecting via SSH, and running the example (on Asahi Linux). Previously this panics, but with this change it runs normally.

Considerations

  • One could argue that ultimately the user should not need to remove WinitPlugin, and instead bevy should only throw the above panic when the application first attempts to create a window.

WinitPlugin panics when there is no display server.
This change removes WinitPlugin because it is a windowless example.
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@mnmaita mnmaita added C-Examples An addition or correction to our examples A-Windowing Platform-agnostic interface layer to run your app in D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 10, 2024
@cxreiff
Copy link
Author

cxreiff commented Oct 11, 2024

Related to this change: from my own testing, the WindowPlugin settings above my change (e.g. setting primary_window to None) are not required, as they are redundant with adding ScheduleRunnerPlugin, which replaces the bevy_winit app runner and prevents a window from being created. Are there non-obvious performance reasons that the primary_window should be manually set to None? Or can these lines be removed?

DefaultPlugins.set(WindowPlugin {
   primary_window: None,
   exit_condition: bevy::window::ExitCondition::DontExit,
   close_when_requested: false,
}),

@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon S-Needs-Testing Testing must be done before this is safe to merge labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Examples An addition or correction to our examples D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-Testing Testing must be done before this is safe to merge X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants