gfx-rs/wgpu · error

Only Opaque/Auto or PreMultiplied alpha mode are supported o

Error message

Only Opaque/Auto or PreMultiplied alpha mode are supported on web

What it means

Panic during Surface::configure on the WebGPU backend: the requested CompositeAlphaMode is PostMultiplied (or another unsupported mode), which browsers reject; only Opaque, Auto, and PreMultiplied map to the web alpha-compositing model. The faulty input is config.alpha_mode.

Source

Thrown at wgpu/src/backend/webgpu.rs:4377

        match self.canvas {
            Canvas::Canvas(ref canvas) => {
                canvas.set_width(config.width);
                canvas.set_height(config.height);
            }
            Canvas::Offscreen(ref canvas) => {
                canvas.set_width(config.width);
                canvas.set_height(config.height);
            }
        }

        if let wgt::PresentMode::Mailbox | wgt::PresentMode::Immediate = config.present_mode {
            panic!("Only FIFO/Auto* is supported on web");
        }
        if let wgt::CompositeAlphaMode::PostMultiplied | wgt::CompositeAlphaMode::Inherit =
            config.alpha_mode
        {
            panic!("Only Opaque/Auto or PreMultiplied alpha mode are supported on web");
        }
        let alpha_mode = match config.alpha_mode {
            wgt::CompositeAlphaMode::PreMultiplied => webgpu_sys::GpuCanvasAlphaMode::Premultiplied,
            _ => webgpu_sys::GpuCanvasAlphaMode::Opaque,
        };
        let mapped = webgpu_sys::GpuCanvasConfiguration::new(
            &device.inner,
            map_texture_format(config.format),
        );
        mapped.set_usage(config.usage.bits());
        mapped.set_alpha_mode(alpha_mode);
        match config.color_space {
            // `Auto` intentionally keeps the browser defaults (colorSpace
            // "srgb", standard tone mapping) even for fp16 formats, matching
            // wgpu's historical behavior on the web.
            wgt::SurfaceColorSpace::Auto | wgt::SurfaceColorSpace::Srgb => {}
            wgt::SurfaceColorSpace::DisplayP3 => {
                // The vendored bindings have no `colorSpace` setter, so set

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Use CompositeAlphaMode::Opaque, PreMultiplied, or Auto on the web
  2. Query get_composite_alpha_modes() on the surface capabilities and select from the supported set
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at wgpu/src/backend/webgpu.rs:4377 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/b5d5a6d35f442580. Report an issue: GitHub.