request_adapter requires specific configuration to succeed with webgl feature enabled #5190
Labels
area: api
Issues related to API surface
area: documentation
Documentation for crate items, public or private
type: bug
Something isn't working
Description
When enabling
webgl
feature and running on wasm target,Instance::request_adapter
requires one of the following to be true, otherwise it will fail with no informative error:backends: wgpu::Backends::GL
should be used when creating the instance (see OnlyGL
Backend on WASM is allowed whenwebgl
feature is enabled #3847 )compatible_surface
must be provided when callingrequest_adapter
(e.g. created from anOffscreenCanvas
etc.).Note the documentation of
request_adapter
doesn't specifycompatible_surface
may be required in some cases, and the documentation ofbackends
doesn't imply that choosing more than justGL
may cause no adapter to be provided.Repro steps
Run the following in wasm with the
webgl
feature - theexpect
will fail.Running without the
webgl
feature - it works.Creating a
Surface
and passing it in thecompatible_surface
would also make it work, which is very surprising.Using
wgpu::Backends::GL
forbackends
would also make it work, which is strange - I would not have expected lowering restrictions to make it work.Expected vs observed behavior
Expected adapter to be available, or for it to be clearly documented in either
Instance::new
orInstance::request_adapter
thatcompatible_surface
may be required in some cases, or that allowing more backends may unintuitively cause adapter to be unavailable.Observed: fails every time, unless using one of the workarounds described above.
Extra materials
N/A
Platform
Tried with wgpu 0.18 and 0.19.1 - same observed behavior.
Tried with Chrome 120.0.6099.234 and Firefox 120.0.1 - same observed behavior.
Running on MacOS 13.6.1
The text was updated successfully, but these errors were encountered: