CanvasRenderingContext is broken after being sized to 0 and back

VERIFIED FIXED in Firefox 6

Status

()

Core
Canvas: 2D
VERIFIED FIXED
6 years ago
3 years ago

People

(Reporter: Pierre Bertet, Assigned: Benjamin)

Tracking

({regression, testcase})

6 Branch
mozilla6
All
Other
regression, testcase
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox5 unaffected, firefox6+ fixed, firefox7 fixed, firefox8 fixed)

Details

Attachments

(2 attachments, 2 obsolete attachments)

(Reporter)

Description

6 years ago
Created attachment 544998 [details]
firefox6-putimagedata.html

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110705195857

Steps to reproduce:

Here is a test (attached too): http://dl.dropbox.com/u/360991/tmp/firefox6-putimagedata.html


Actual results:

The first canvas is not drawn on the second one.


Expected results:

The first canvas should be drawn on the second one.
If I click the button once, the line from the first canvas is drawn on the second.

If I click the button again, both canvases become blank.

In Webkit (Safari 5, specifically) clicking the button more than once has no visual effect.
Status: UNCONFIRMED → NEW
tracking-firefox6: --- → ?
Ever confirmed: true
Keywords: regression, regressionwindow-wanted
Created attachment 545045 [details] [diff] [review]
Reftest
Attachment #544998 - Attachment is obsolete: true
Keywords: testcase
This is a regression from Bug 421865.
Blocks: 421865
Keywords: regressionwindow-wanted
status-firefox5: --- → unaffected
status-firefox6: --- → affected
status-firefox7: --- → affected
status-firefox8: --- → affected
I think we should back out bug 421865 on trunk and branches. Joe, can you do that?
I think the fix is trivial.  Testing now.
(Assignee)

Updated

6 years ago
Assignee: nobody → benjamin
(Assignee)

Comment 6

6 years ago
Created attachment 545084 [details] [diff] [review]
reset mZero when new dimensions are set
Attachment #545084 - Flags: review?(joe)

Comment 7

6 years ago
We are going to track this since it seems like something needs to be done if we are proposing to back this out on nightly. Cc'ing Asa on the bug.
tracking-firefox6: ? → +
I think we should probably just take the fix (once reviewed and checked in on central, of course) but something will have to be done.
Comment on attachment 545084 [details] [diff] [review]
reset mZero when new dimensions are set

Review of attachment 545084 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry for not catching this in review!

::: content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ +1067,2 @@
>          // Zero sized surfaces have problems, so just use a 1 by 1.
>          if (height == 0 || width == 0) {

I think I'd rather have the mZero = PR_FALSE in an else block, but I don't feel strongly about it, so do what feels more natural.

::: content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ +1225,2 @@
>    // Zero sized surfaces cause issues, so just go with 1x1.
>    if (height == 0 || width == 0) {

Same as the other mZero.
Attachment #545084 - Flags: review?(joe) → review+
(Assignee)

Comment 10

6 years ago
Created attachment 545388 [details] [diff] [review]
fixes style nits; ready for landing
Attachment #545084 - Attachment is obsolete: true
(Assignee)

Updated

6 years ago
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/5dd671d71bb2
http://hg.mozilla.org/mozilla-central/rev/1c0a3850afa2
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
Keywords: checkin-needed
Comment on attachment 545388 [details] [diff] [review]
fixes style nits; ready for landing

Drivers, this low-risk (adds two lines of code) patch fixes a web-facing regression in <canvas> from Bug 421865, which landed for Firefox 6.
Attachment #545388 - Flags: approval-mozilla-beta?
Attachment #545388 - Flags: approval-mozilla-aurora?

Updated

6 years ago
Attachment #545388 - Flags: approval-mozilla-beta?
Attachment #545388 - Flags: approval-mozilla-beta+
Attachment #545388 - Flags: approval-mozilla-aurora?
Attachment #545388 - Flags: approval-mozilla-aurora+
http://hg.mozilla.org/releases/mozilla-aurora/rev/cc0754f90ad8
http://hg.mozilla.org/releases/mozilla-aurora/rev/7fae5c9da3cf
http://hg.mozilla.org/releases/mozilla-beta/rev/f441d792ee63
http://hg.mozilla.org/releases/mozilla-beta/rev/15ff31073de8

Thanks Pierre for the bug report, and thanks Benjamin for the speedy fix!
status-firefox6: affected → fixed
status-firefox7: affected → fixed
status-firefox8: affected → fixed
Target Milestone: mozilla8 → mozilla6
Summary: putImageData (or getImageData) bug with Firefox 6beta+ → CanvasRenderingContext is broken after being sized to 0 and back

Comment 14

6 years ago
Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0 - beta 2

I've just tried to verify this issue but it's unclear to me whether it is fixed or not.

On Fx beta 6 (on Ubuntu 11.04 and WinXP), using the testcase from Comment 0, if I press once the canvas is copied and if I press a second time nothing happens. On Nightly and Aurora pushing the button twice clears the two image areas. 

On Mac OS X 10.7 Nightly, Aurora an Beta builds display the same behavior: on the second click on the button, nothing changes.

Can you please clarify this?

Thanks!
(Reporter)

Comment 15

6 years ago
George: On the second click, nothing should changes.

When the bug was reported, with Firefox 6 beta, 7 and 8, the two canvas were erased.

Tested with the repo tip on OS X 10.6, it works for me now (nothing happens on the second click).

Comment 16

6 years ago
Yes, on Mac OS builds everything works as expected - the second click does nothing. The problem still persists on Windows and Linux builds as I mentioned in Comment 14.
I see the expected behavior on Windows on http://hg.mozilla.org/releases/mozilla-aurora/rev/ce993f19fc4ba and http://hg.mozilla.org/mozilla-central/rev/931f06b80727 ....

Comment 18

6 years ago
Mozilla/5.0 (X11; Linux i686; rv:8.0a1) Gecko/20110717 Firefox/8.0a1

Rechecked on Nightly, Aurora and 6 Beta 2 and everything seems in order across platforms. It looks like the patch hadn't landed yet when I tried to verify.

The issue is no longer reproducible on all three builds on WinXP, Ubuntu 11.04, Win 7 and Mac OS X 10.7.

Setting status to Verified Fixed.

Thanks guys and sorry for the small confusion.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.