WASM: let the app work if the GL context is lost
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
Any using WASM (webgl or webgpu).
## What you did
The app panics if the WebGL context is lost in these 2 main scenarios (they are not 2 different bugs, it's the same one, happening for 2 different reasons):
1. it doesn't exist from the beginning (i.e. the GPU doesn't provide a WebGL2 renderer)
2. it's lost during the execution (e.g. for high memory usage reasons).
To reproduce 1. (both webgl and webgpu), disable graphics acceleration in Chrome in the settings, and run the app.
To reproduce 2. (webgl only), run this in the browser console when the app is running:
```
let canvas = document.querySelector("canvas");
let gl = canvas.getContext("webgl2");
let extension = gl.getExtension("WEBGL_lose_context");
extension.loseContext();
```
I'd expect the app to continue running so that the user can be notified and/or the app tries to restore the context (some steps need to be done in Winit for that).
I did not find a webgpu equivalent API to trigger/simulate a context loss.
Contributor guide
Research direction
Start by reproducing the missing and lost WebGL context cases in Chrome using the provided settings and browser-console steps, then inspect the WASM rendering path and the Winit work mentioned in the issue. Done means the app no longer panics when WebGL or WebGPU is unavailable or the WebGL context is lost, and it can notify the user or attempt restoration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100