diff --git a/wgpu-hal/src/gles/web.rs b/wgpu-hal/src/gles/web.rs index 49bc5656de..02cd6a3ecb 100644 --- a/wgpu-hal/src/gles/web.rs +++ b/wgpu-hal/src/gles/web.rs @@ -25,6 +25,7 @@ impl AdapterContext { #[derive(Debug)] pub struct Instance { + /// Set when a canvas is provided, and used to implement [`Instance::enumerate_adapters()`]. webgl2_context: Mutex>, } @@ -82,6 +83,8 @@ impl Instance { .dyn_into() .expect("canvas context is not a WebGl2RenderingContext"); + // It is not inconsistent to overwrite an existing context, because the only thing that + // `self.webgl2_context` is used for is producing the response to `enumerate_adapters()`. *self.webgl2_context.lock() = Some(webgl2_context.clone()); Ok(Surface {