Closed Bug 1794956 Opened 3 years ago Closed 3 years ago

transferToimageBitmap should not reset the context

Categories

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

Firefox 107
defect

Tracking

()

VERIFIED FIXED
107 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox105 --- wontfix
firefox106 --- wontfix
firefox107 --- verified

People

(Reporter: tristan.fraipont, Assigned: jgilbert)

References

(Blocks 1 open bug)

Details

(Keywords: correctness, reproducible)

Attachments

(4 files)

Attached file test-case.html

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0

Steps to reproduce:

https://jsfiddle.net/am16Lhk4/

  1. Set some properties to an OffscreenCanvas's 2D context, like fillStyle, or changing its CTM.
  2. Call the OffscreenCanvas's transferToImageBitmap() method.
  3. Perform new drawings without resetting the properties set at step 1.

Actual results:

All the properties set at step 1 where reset to their default.

Expected results:

Per specs only the bitmap buffer is supposed to get cleared by this operation, the context's properties are supposed to be preserved.

Triage - assigning S2 initially. I will see if mozregression reveals a working version.

Blocks: gfx-triage
Severity: -- → S2

To see if this is a regression I did mozregression using the provided test page, this feature used to be broken in a worse way as far back as FF95 (the actual result boxes are blank). As of FF104 it looks like the result in comment #2, which is broken in the way described in comment #1.

NeedInfo - Any additional info we will need to be able to address this bug?

Flags: needinfo?(aosmond)
Status: UNCONFIRMED → NEW
Has STR: --- → yes
Ever confirmed: true
Assignee: nobody → jgilbert

We guessed wrong here, and we should not be resetting here:
https://searchfox.org/mozilla-central/rev/76ccfc801e6b736c844cde3fddeab7a748fc8515/dom/canvas/OffscreenCanvas.cpp#267-271

    // FIXME(aosmond): The spec is unclear about the state of the canvas after
    // clearing. Does it expect to preserve the WebGL state, other than the
    // buffer state? Once we have clarity, we should ensure we clear the WebGL
    // canvas as desired.
    mCurrentContext->Reset();
Flags: needinfo?(aosmond) → needinfo?(jgilbert)

s/Reset/ResetBitmap/ and implement for WebGL and WebGPU.

That fixes the testcase behavior.
We need (more? fixed?) tests for this though, so let me add those here.

Flags: needinfo?(jgilbert)
Priority: -- → P1
Blocks: 1795521
Pushed by jgilbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3abcf6ccf88a TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/7b3067b086e6 Repair and enable test_offscreencanvas_toimagebitmap.html. r=gfx-reviewers,lsalzman

Backed out for causing wpt failures on offscreencanvas.transfer.to.imagebitmap.html.

This fails on multiple platforms.
Push where the failures appeared
Push with failures

Failure log

Backout link

[task 2022-10-15T15:38:15.430Z] 15:38:15     INFO - TEST-START | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html
[task 2022-10-15T15:38:15.434Z] 15:38:15     INFO - Closing window a451e800-7db1-451d-869b-2997a2056bd1
[task 2022-10-15T15:38:15.509Z] 15:38:15     INFO - 
[task 2022-10-15T15:38:15.509Z] 15:38:15     INFO - TEST-PASS | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html | Test that transferToImageBitmap returns an ImageBitmap with correct width and height 
[task 2022-10-15T15:38:15.510Z] 15:38:15     INFO - TEST-PASS | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html | Test that transferToImageBitmap returns an ImageBitmap with correct color 
[task 2022-10-15T15:38:15.510Z] 15:38:15     INFO - TEST-UNEXPECTED-PASS | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html | Test that transferToImageBitmap won't change context's property - expected FAIL
[task 2022-10-15T15:38:15.510Z] 15:38:15     INFO - TEST-INFO | expected FAIL
[task 2022-10-15T15:38:15.511Z] 15:38:15     INFO - 
[task 2022-10-15T15:38:15.511Z] 15:38:15     INFO - TEST-UNEXPECTED-PASS | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html | Test that transferToImageBitmap preserves transform - expected FAIL
[task 2022-10-15T15:38:15.511Z] 15:38:15     INFO - TEST-INFO | expected FAIL
[task 2022-10-15T15:38:15.512Z] 15:38:15     INFO - ..
[task 2022-10-15T15:38:15.512Z] 15:38:15     INFO - TEST-OK | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.html | took 80ms
[task 2022-10-15T15:38:15.514Z] 15:38:15     INFO - PID 2188 | 1665848295510	Marionette	INFO	Stopped listening on port 59578
[task 2022-10-15T15:38:15.811Z] 15:38:15     INFO - PID 2188 | [2022-10-15T15:38:15Z ERROR xulstore::persist] removeDocument error: unavailable
[task 2022-10-15T15:38:15.841Z] 15:38:15     INFO - Browser exited with return code 0
[task 2022-10-15T15:38:15.844Z] 15:38:15     INFO - Closing logging queue
[task 2022-10-15T15:38:15.844Z] 15:38:15     INFO - queue closed
[task 2022-10-15T15:38:16.014Z] 15:38:16     INFO - Application command: /opt/worker/tasks/task_166584702349171/build/application/Firefox Nightly.app/Contents/MacOS/firefox --marionette about:blank -foreground -profile /var/folders/s_/lbx5y22n31l0w_7s1y123mzw000014/T/tmp21rji15v
[task 2022-10-15T15:38:16.023Z] 15:38:16     INFO - PID 2246 | 1665848202123	Marionette	INFO	Marionette enabled
[task 2022-10-15T15:38:16.023Z] 15:38:16     INFO - PID 2246 | 1665848202148	Marionette	INFO	Listening on port 59820
[task 2022-10-15T15:38:16.024Z] 15:38:16     INFO - PID 2246 | console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /var/folders/s_/lbx5y22n31l0w_7s1y123mzw000014/T/tmpb5qrv6yh/search.json.mozlz4", (void 0)))
[task 2022-10-15T15:38:16.025Z] 15:38:16     INFO - PID 2246 | 2022-10-15 15:37:12.090 firefox[2246:55147] Persistent UI failed to open file file:///Users/cltbld/Library/Saved%20Application%20State/org.mozilla.nightly.savedState/window_1.data: No such file or directory (2)
[task 2022-10-15T15:38:16.025Z] 15:38:16     INFO - Starting runner
[task 2022-10-15T15:38:16.628Z] 15:38:16     INFO - TEST-START | /html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.nocrash.html
[task 2022-10-15T15:38:16.720Z] 15:38:16     INFO - .
Flags: needinfo?(jgilbert)
Pushed by jgilbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/78a3979d12d7 TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/1324acbcc0e2 Repair and enable test_offscreencanvas_toimagebitmap.html. r=gfx-reviewers,lsalzman
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
QA Whiteboard: [qa-107b-p2]
Flags: needinfo?(jgilbert)

I managed to reproduce this issue on a 2022-10-12 Nightly build on macOS 12 using the testcase attached in Comment 0. Verified as fixed on Firefox 107.0b4(build ID: 20221023190001), Nightly 108.0a1(build ID: 20221023100414) on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-107b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: