script: Let HTMLCanvasElement manage the ImageKey for canvases#40375
script: Let HTMLCanvasElement manage the ImageKey for canvases#40375mukilan merged 4 commits intoservo:mainfrom
HTMLCanvasElement manage the ImageKey for canvases#40375Conversation
c0bb55a to
4277436
Compare
|
🔨 Triggering try run (#19044544341) for Linux (WPT) |
|
Test results for linux-wpt from try job (#19044544341): Flaky unexpected result (18)
Stable unexpected results that are known to be intermittent (29)
Stable unexpected results (3)
|
|
|
components/script/dom/document.rs
Outdated
| let mut dirty_canvases = self.dirty_canvases.borrow_mut(); | ||
| if dirty_canvases | ||
| .iter() | ||
| .any(|dirty_canvas| std::ptr::eq(&**dirty_canvas, canvas)) |
There was a problem hiding this comment.
If we import the DomObject trait, we can use the PartialEq of dom structs to do dirty_canvas.reflector() == canvas.reflector().
Or even better, since we create Never mind, we can't have the Dom::ref(canvas) in the last line of the method, we can move it up before this line and just do *dirty_canvas == canvas.Dom on the stack.
mukilan
left a comment
There was a problem hiding this comment.
Looks like there is a regression in /_webgl/conformance/canvas/buffer-offscreen-test.html. I'll look into it.
The issue is that the failing case checks the behaviour of offscreen canvas i.e a Previously, the The new logic doesn't do this filtering in I believe we just need add the following check to This matches what we have for |
|
🔨 Triggering try run (#19061476730) for Linux (WPT) |
4b86660 to
586cac7
Compare
|
🔨 Triggering try run (#19061720001) for Linux (WPT) |
|
I've triggered a new try run after rebasing as the previous one failed since CI now passes |
|
Test results for linux-wpt from try job (#19061720001): Flaky unexpected result (42)
Stable unexpected results that are known to be intermittent (30)
|
|
✨ Try run (#19061720001) succeeded. |
This change makes it so that the `HTMLCanvasElement` is responsible for managing the `ImageKey` for assocaited `RenderingContext`s. Only canvases display their contents into WebRender directly, so this makes it so that keys are not generated for `OffscreenCanvas`. The main goal here is that `ImageKey`s are always associated with a particular `WebView`, which isn't possible in the various canvas backends yet. This is important because each `Webview` may soon have a different WebRender instance entirely with its own set of `ImageKey`s. This also allows for clearing `ImageKey`s when canvases are disconnected from the DOM in a future change. One tricky thing here is placeholder canvases, which are meant to be driven from workers. It seems that the implementation isn't correct for these at the moment as they need to be updated to the specification. Instead, what is happening is that any existing context / image is completely lost when converting to an `OffscreenCanvas`. Co-authored-by: Mukilan Thiyagarajan <[email protected]> Signed-off-by: Martin Robinson <[email protected]>
Signed-off-by: Mukilan Thiyagarajan <[email protected]>
Signed-off-by: Mukilan Thiyagarajan <[email protected]>
586cac7 to
11680e2
Compare
Signed-off-by: Mukilan Thiyagarajan <[email protected]>
This change makes it so that the
HTMLCanvasElementis responsible formanaging the
ImageKeyfor associatedRenderingContexts. Onlycanvases display their contents into WebRender directly, so this makes
it so that keys are not generated for
OffscreenCanvas.The main goal here is that
ImageKeys are always associated with aparticular
WebView, which isn't possible in the various canvasbackends yet. This is important because each
WebViewmay soon have adifferent WebRender instance entirely with its own set of
ImageKeys.This also allows for clearing
ImageKeys when canvases are disconnectedfrom the DOM in a future change. One tricky thing here is placeholder
canvases, which are meant to be driven from workers.
It seems that the implementation isn't correct for these at the moment
as they need to be updated to the specification. Instead, what is
happening is that any existing context / image is completely lost when
converting to an
OffscreenCanvas.Testing: This shouldn't change observable behavior, so is covered by
existing tests.
Fixes: This is part of #40261.