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

Provide a way to suspend the renderer when running in background #2296

Open
HackerFoo opened this issue Jun 2, 2021 · 8 comments
Open

Provide a way to suspend the renderer when running in background #2296

HackerFoo opened this issue Jun 2, 2021 · 8 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@HackerFoo
Copy link
Contributor

What problem does this solve or what need does it fill?

Rendering can consume power unnecessarily when running in the background in a multitasking OS. For this reason, mobile OSes such as iOS do not allow use of the GPU by background tasks.

What solution would you like?

I would like a way to suspend the renderer, or maybe plugins in general, in some states.

What alternative(s) have you considered?

I have considered serializing state and exiting the main loop, but this isn't supported for iOS.

Additional context

Without this feature, if the app uses the GPU on iOS, it will be killed with this message:

Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (IOAF code 6)

@HackerFoo HackerFoo added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jun 2, 2021
@alyti
Copy link

alyti commented Jun 2, 2021

related to #2018

@HackerFoo
Copy link
Contributor Author

Also sort of related to #1343, to save power when there is nothing to do, especially in the background.

@cart
Copy link
Member

cart commented Jun 2, 2021

Also probably relates to similar issues on android related to "losing context on minimization" in #86. The "pipelined rendering" work (#2265) might play into this, as it decouple render logic from app logic.

@NathanSWard NathanSWard added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Jun 2, 2021
bors bot pushed a commit that referenced this issue Jul 16, 2021
# Objective

This fixes a crash caused by iOS preventing GPU access when not focused: #2296

## Solution

This skips `app.update()` in `winit_runner` when `winit` sends the `Suspended` event, until `Resumed`.

I've tested that this works for me on my iOS app.
ostwilkens pushed a commit to ostwilkens/bevy that referenced this issue Jul 27, 2021
# Objective

This fixes a crash caused by iOS preventing GPU access when not focused: bevyengine#2296

## Solution

This skips `app.update()` in `winit_runner` when `winit` sends the `Suspended` event, until `Resumed`.

I've tested that this works for me on my iOS app.
@blaind
Copy link
Contributor

blaind commented Aug 3, 2021

Related to Lifecycle API (#2432) too, the same renderer pausing state would be needed for XR also.

@blaind blaind mentioned this issue Aug 3, 2021
@aevyrie
Copy link
Member

aevyrie commented Mar 4, 2022

This is at least partially solved by #3974. We could extend this by exposing Wait instead of WaitUntil. That should completely suspend the event loop until interacted with. WaitUntil will wake the loop once the timeout has been reached. We could technically use it as is, and just set the timeout to be 900 years or something silly.

I can't test this PR on iOS, but on my system it behaves as expected and outright stops using the GPU.

@HackerFoo
Copy link
Contributor Author

HackerFoo commented Mar 4, 2022

It might be useful to still be able to use the CPU in the background. This is also related to the ability to run headless - it can be seen as the ability to switch to headless mode and back at runtime.

@mdickopp
Copy link
Contributor

Possibly related to #4579 and #3380.

@aevyrie
Copy link
Member

aevyrie commented Apr 25, 2022

It might be useful to still be able to use the CPU in the background. This is also related to the ability to run headless - it can be seen as the ability to switch to headless mode and back at runtime.

@HackerFoo so this might instead be solved by not running the render subapp, instead of pausing the winit event loop? (but continuing to run the main app)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

7 participants