Closed Bug 1765816 Opened 2 years ago Closed 2 years ago

Firefox Screenshot missing canvas content

Categories

(Core :: Graphics: Canvas2D, defect, P3)

defect

Tracking

()

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

Details

Attachments

(1 file, 1 obsolete file)

With a context owned by OffscreenCanvas this works, but with a context owned directly by HTMLCanvasElement, it does not. This is because nsDisplayCanvas::Paint relies upon GetAsImage:

https://searchfox.org/mozilla-central/rev/6f6cf2810742d32454251afdb8e632c27999bea7/layout/generic/nsHTMLCanvasFrame.cpp#313

which for Canvas 2D, WebGL and WebGPU use the default implementation:

https://searchfox.org/mozilla-central/rev/6f6cf2810742d32454251afdb8e632c27999bea7/dom/canvas/nsICanvasRenderingContextInternal.h#150

which always returns null. We should return the front buffer contents.

This patch adds support for including the canvas contents in Firefox
Screenshots for Canvas 2D, WebGL and WebGPU. It is already working for
context's created through an OffscreenCanvas, but we failed to hook up
the main thread path after refactoring in previous bugs.

Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/505897037daf Expose front buffer canvas contents when painting for Firefox Screenshots. r=gfx-reviewers,lsalzman
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2f074e2385d4 Expose front buffer canvas contents when painting for Firefox Screenshots. r=gfx-reviewers,lsalzman
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch

Backed out along with Bug 1755704 for causing reftest failures on webgl-color-test.html

[task 2022-04-23T23:09:30.555Z] 23:09:30     INFO - REFTEST TEST-START | dom/canvas/test/reftest/webgl-color-test.html?frame=1&__&________&_______&_____ == dom/canvas/test/reftest/wrapper.html?colors-no-alpha.png
[task 2022-04-23T23:09:30.559Z] 23:09:30     INFO - REFTEST INFO | RESTORE PREFERENCE pref(webgl.force-enabled,false)
[task 2022-04-23T23:09:30.559Z] 23:09:30     INFO - REFTEST INFO | SET PREFERENCE pref(webgl.force-enabled,true)
[task 2022-04-23T23:09:30.559Z] 23:09:30     INFO - REFTEST TEST-LOAD | file:///builds/worker/workspace/build/tests/reftest/tests/dom/canvas/test/reftest/webgl-color-test.html?frame=1&__&________&_______&_____ | 9 / 173 (5%)
[task 2022-04-23T23:09:30.608Z] 23:09:30     INFO - [Parent 2087, Compositor] WARNING: robust_buffer_access_behavior marked as unsupported: file /builds/worker/checkouts/gecko/gfx/gl/GLContextFeatures.cpp:632
[task 2022-04-23T23:09:30.609Z] 23:09:30     INFO - [Parent 2087, Compositor] WARNING: Robustness supported, strategy is not LOSE_CONTEXT_ON_RESET!: file /builds/worker/checkouts/gecko/gfx/gl/GLContext.cpp:999
[task 2022-04-23T23:09:30.609Z] 23:09:30     INFO - [Parent 2087, Compositor] WARNING: robustness marked as unsupported: file /builds/worker/checkouts/gecko/gfx/gl/GLContextFeatures.cpp:632
[task 2022-04-23T23:09:30.653Z] 23:09:30     INFO - [Parent 2087, Compositor] WARNING: Failed to make an ideal SurfaceFactory.: file /builds/worker/checkouts/gecko/dom/canvas/WebGLContext.cpp:955
[task 2022-04-23T23:09:30.717Z] 23:09:30     INFO - REFTEST INFO | RESTORE PREFERENCE pref(webgl.force-enabled,false)
[task 2022-04-23T23:09:30.720Z] 23:09:30     INFO - REFTEST INFO | SET PREFERENCE pref(webgl.force-enabled,true)
[task 2022-04-23T23:09:30.721Z] 23:09:30     INFO - REFTEST TEST-LOAD | file:///builds/worker/workspace/build/tests/reftest/tests/dom/canvas/test/reftest/wrapper.html?colors-no-alpha.png | 9 / 173 (5%)
[task 2022-04-23T23:09:31.130Z] 23:09:31     INFO - REFTEST TEST-UNEXPECTED-FAIL | dom/canvas/test/reftest/webgl-color-test.html?frame=1&__&________&_______&_____ == dom/canvas/test/reftest/wrapper.html?colors-no-alpha.png | image comparison, max difference: 127, number of differing pixels: 40000
Status: RESOLVED → REOPENED
Flags: needinfo?(aosmond)
Resolution: FIXED → ---
Target Milestone: 101 Branch → ---
Flags: needinfo?(aosmond)
Attachment #9273273 - Attachment is obsolete: true

I will just target this with WebGPU. While I did test before and after and I didn't get the contents for a WebGL demo I tried, clearly there is code working already for it and my change made things worse (the yflip didn't happen for WebGL -- canvas 2D would have been fine).

Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8c743211b6fb Expose front buffer canvas contents when painting for Firefox Screenshots for WebGPU. r=gfx-reviewers,lsalzman
Status: REOPENED → RESOLVED
Closed: 2 years ago2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: