canvas: fix unrecognized offscreen webgl context#44159
Conversation
Signed-off-by: Niya Gupta <[email protected]>
|
Creating a draft PR with compiler errors because I need some help. @jdm I looked at the As part of getting the context step, I need to pass a It does not exist for the offscreen canvas. let window = self.global();
let canvas =
RootedHTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(DomRoot::from_ref(self));
let size = self.get_size();
let attrs = Self::get_gl_attributes(cx, options, can_gc)?;
let context = WebGLRenderingContext::new(
&window,
&canvas,
WebGLVersion::WebGL1,
size,
attrs,
can_gc,
)?;Do we need to create a And use that as a context instead? |
|
Actually the code at and needs to be changed to accept a&GlobalScope, then
needs to be rewritten to downcast the global to a Window or WorkerGlobalScope. Then we'll need to add servo/components/script/dom/window.rs Lines 680 to 684 in 38f77f4 servo/components/script/dom/window.rs Lines 382 to 384 in 38f77f4 |
|
I think you will need to add a webgl_chan member to , and then you can access it from WorkerGlobalScope::new. Then you can add a webgl_chan argument to and get it from the globals at the callsites by (again) downcasting them to Window or WorkerGlobalScope. |
|
@jdm While calling Expects a servo/components/script/dom/window.rs Lines 680 to 684 in 38f77f4 How should I go about returning |
|
That's fun! I suggest adding a temporary method to Window to return the WebGLChan until #44193 is fixed. |
Signed-off-by: Niya Gupta <[email protected]>
|
Thanks for the help @jdm! That said, I still need to work on some stuff: In the servo/components/script/dom/canvas/2d/canvas_state.rs Lines 674 to 675 in d11fc3a Same for the servo/components/script/dom/canvas/2d/canvas_state.rs Lines 781 to 785 in d11fc3a I copied an unsafe method and implemented it on the I think this should be okay, although, I am not sure if there is a better way. Test Result Summary
Details |
|
Exciting! This is looking really good! |
Signed-off-by: Niya Gupta <[email protected]>
e240528 to
dc758c1
Compare
Signed-off-by: Niya Gupta <[email protected]>
Signed-off-by: Niya Gupta <[email protected]>
| self.global() | ||
| .downcast::<Window>() | ||
| .and_then(|window| { |
There was a problem hiding this comment.
Aha, we can file a followup issue about updating WebGLRenderingContext::new to accept a &GlobalScope argument instead.
Signed-off-by: Niya Gupta <[email protected]>
|
🔨 Triggering try run (#24417719696) for Linux (WPT) |
|
Test results for linux-wpt from try job (#24417719696): Flaky unexpected result (34)
Stable unexpected results that are known to be intermittent (17)
Stable unexpected results (13)
|
|
|
Signed-off-by: Niya Gupta <[email protected]>
|
Let's merge this as is :) |
fix unrecognized type error on
OffscreenCanvasTesting: existing WPT:
tests/wpt/webgl/tests/conformance/offscreencanvastests/wpt/webgl/tests/conformance2/offscreencanvasFixes: #43540