Skip to content

WASM: let the app work if the GL context is lost #12681

Open
@beoboo

Description

@beoboo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WindowingPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsP-CrashA sudden unexpected crash

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions