These changes fix #30843 (#30888)

Signed-off-by: Lucas Fabián Montenegro <40044087+lucasMontenegro@users.noreply.github.com>
This commit is contained in:
Lucas Montenegro 2023-12-20 02:57:48 -03:00 committed by GitHub
parent 8bbcf0abaf
commit 256ab5353b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 40 deletions

View file

@ -269,11 +269,15 @@ impl HTMLCanvasElement {
.global()
.script_to_constellation_chan()
.send(ScriptMsg::GetWebGPUChan(sender));
let window = window_from_node(self);
let channel = receiver.recv().expect("Failed to get WebGPU channel");
let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel);
*self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context)));
Some(context)
receiver
.recv()
.expect("Failed to get WebGPU channel")
.map(|channel| {
let window = window_from_node(self);
let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel);
*self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context)));
context
})
}
/// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists.