Skip to content

WebGPU support detection doesn't handle failure at getContext() #5332

Open
@kpreid

Description

@kpreid

Description
Enabling the "webgpu" backend can cause WebGL support to be lost.

Repro steps

  1. Use Firefox 123.0 on macOS.
  2. Set dom.webgpu.enabled to true.
  3. Visit https://wgpu.rs/examples/?backend=webgl2&example=bunnymark

Expected vs observed behavior
Expected: The demo should display, using either webgpu or webgl2.
Observed: it fails to initialize:
CreateSurfaceError { inner: Web("canvas.getContext() returned null; webgpu not available or canvas already in use") }

WebGPU detection is presumably concluding WebGPU is supported because navigator.gpu exists, but that is evidently not sufficient.

(Note that it is also possible for a canvas to return null for the context simply because it was previously used as "webgl2" rather than "webgpu". That would be nice to support too, but since it would require a simultaneous WebGPU-or-WebGL2 backend, understandable to skip.)

Platform

  • Firefox 123.0
  • macOS
  • wgpu 0.19.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend: webgpuIssues with direct interface with WebGPUtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions