[wpt-sync] Sync PR 65124 - Clone single-buffered 2D canvas in BaseRenderingContext2D::Snapshot()
Categories
(Core :: Graphics: Canvas2D, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 65124 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/65124
Details from upstream follow.
Jean-Philippe Gravel <jpgravel@chromium.org> wrote:
Clone single-buffered 2D canvas in BaseRenderingContext2D::Snapshot()
The 2D canvas has a copy-on-write mechanism allowing the rasterized
canvas output texture to be directly given to the compositor, or to the
web page (if it does a readback) without copying it. The texture is
only copied onto a new one if the canvas continues drawing into that
same buffer while a reference is still held by readers 1.Desynchronized canvases however are single-buffered and meant to be read
and written concurrently. The compositor will keep a reference to the
texture and copy-on-write has to be disabled for writes to happen to
that same texture 2.This is a problem if the page takes a snapshot of the canvas because if
the texture is never copied, this gives the page direct access to the
texture being actively written by the canvas. If the page does a
readback, holds onto the image buffer and draws cross-origin data, the
cross-origin data becomes immediately visible from the buffer the page
held onto. The canvas itself becomes tainted, but the snapshot remains
origin-clean and readable by the page.The best solution would be to implement copy-on-write for desynchronized
canvases. But, this is not easy to do because the canvas does not
currently know whether the readers holding a reference on the resource
are the compositor or the page. The copy should also work in reverse to
normal copy-on-write. Normally, we use the copy as the new canvas
backing texture used for new drawing. But for single-buffered textures,
the original texture should remain bound to the renderer and compositor,
and the copy should be given to the page (with CONCURRENT_READ_WRITE and
SCANOUT disabled).In the context of fixing this bug with a safe and simple change, this
CL instead opts for cloning the texture early, as soon as a snapshot is
returned to the page. This ensures that cross-origin data is never
leaked.Fixed: 566888176
Change-Id: I17424afafb949332c01a0c93819229071719e843
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8795549
Reviewed-by: Jonathan Lee \<jonathanjlee@google.com>
Commit-Queue: Jean-Philippe Gravel \<jpgravel@chromium.org>
Reviewed-by: Vasiliy Telezhnikov \<vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1743694}
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Comment 1•9 days ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=123279
| Assignee | ||
Comment 2•9 days ago
|
||
CI Results
Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 1 tests and 10 subtests
Status Summary
Firefox
OK : 1
PASS: 10
Chrome
OK : 1
PASS: 10
Safari
OK : 1
PASS: 10
Links
Comment 4•8 days ago
|
||
| bugherder | ||
Description
•