Skip to content

Bevy lets you use ScreenshotManager even if it won't work #11493

@banool

Description

@banool

Bevy version

0.12.1

Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

  • the Rust version you're using (you can get this by running cargo --version)
    • cargo 1.75.0 (1d8b05cdd 2023-11-20)
  • the operating system or browser used, including its version
    • MacOS 14.2.1 (M1 ARM)

What you did

The docs for take_screenshot say this:

The given callback will eventually be called on one of the AsyncComputeTaskPool threads.

When I call take_screenshot it returns happily but the callback is never called. Same issue with save_screenshot_to_disk.

I'm setting up my systems with DefaultPlugins.build().disable::<WinitPlugin>(). I'm guessing that whatever is meant to come along later and make the screenshot happen never happens because I don't have a window.

What went wrong

While this is related to taking a screenshot in headless mode (#7163, #22), my main concern is with the API. If it's true that take_screenshot will never work without a window, one of the following should be true:

  • Calling screenshot_manager.take_screenshot should return an error immediately indicating that screenshots aren't possible bc x y z other plugins are missing.
  • It is impossible to get mut screenshot_manager: ResMut<ScreenshotManager> in the first place, I suppose bc the plugin is removed from the default set automatically if there is now window. Or maybe just because there is no event loop.

Additional information

I understand that without WinitPlugin there is no event loop and the update only runs once, so I wonder if there is a way to force the callback to be called later. It seems that just dropping the App instance doesn't make it happen. I guess it depends on whether taking a screenshot is expected to work without a window or not, and therefore if it relates to the window or the event loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-WindowingPlatform-agnostic interface layer to run your app inC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions