Closed Bug 670442 Opened 13 years ago Closed 13 years ago

CanvasRenderingContext is broken after being sized to 0 and back

Categories

(Core :: Graphics: Canvas2D, defect)

6 Branch
All
Other
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla6
Tracking Status
firefox5 --- unaffected
firefox6 + fixed
firefox7 --- fixed
firefox8 --- fixed

People

(Reporter: hi, Assigned: Benjamin)

References

Details

(Keywords: regression, testcase)

Attachments

(2 files, 2 obsolete files)

Attached file firefox6-putimagedata.html (obsolete) —
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
Ever confirmed: true
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: nobody → benjamin
Attachment #545084 - Flags: review?(joe)
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.
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+
Attachment #545084 - Attachment is obsolete: true
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/5dd671d71bb2
http://hg.mozilla.org/mozilla-central/rev/1c0a3850afa2
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
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?
Attachment #545388 - Flags: approval-mozilla-beta?
Attachment #545388 - Flags: approval-mozilla-beta+
Attachment #545388 - Flags: approval-mozilla-aurora?
Attachment #545388 - Flags: approval-mozilla-aurora+
Summary: putImageData (or getImageData) bug with Firefox 6beta+ → CanvasRenderingContext is broken after being sized to 0 and back
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!
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).
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.
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.

Attachment

General

Creator:
Created:
Updated:
Size: