bevyengine / bevyengine/bevy

Run bevy systems in wasm even when the tab is not focused

Open
#13,368 7 comments 1 reaction 0 assignees View on GitHub
C-Feature O-Web S-Needs-Design X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

It seems like if the user switches to a different tab, the bevy app will basically freeze and stop getting updated.

This seems to be because running the schedule in wasm is tied to `requestAnimationFrame` (https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) calls which are made by winit in the winit_runner.

A potential solution would be:
- if the tab is focused, keep the current scheduling logic
- if the tab is not focused, update the schedule at fixed intervals (for example 60Hz(

Contributor guide

Open the contributing guide

Research direction

Start at the winit_runner scheduling path and read how requestAnimationFrame drives the wasm schedule. Compare focused and unfocused browser behavior, then determine how fixed-interval updates should coexist with the current focused-tab logic. Done means wasm systems continue updating when the tab is unfocused without changing focused-tab scheduling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
game-dev, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.