Bug 60091 - The canvas spec models an edge case after an old bug in CG
Summary: The canvas spec models an edge case after an old bug in CG
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-03 17:27 PDT by Matthew Delaney
Modified: 2014-04-05 14:08 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Delaney 2011-05-03 17:27:44 PDT
It appears that this edge case in the canvas spec...

"Shadows are only drawn if the opacity component of the alpha component of the color of shadowColor is non-zero and either the shadowBlur is non-zero, or the shadowOffsetX is non-zero, or the shadowOffsetY is non-zero."

...is modeled after a bug that CG had/has. In destination-atop, the shadow should be rendered atop the source. However, if you have a shadowBlur of 0 (or very close to 0), then CG will just not render the shadow. The philip canvas test suite has a test to check for this edge case at: http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html

Here's a testcase that jamesr constructed that shows the discontinuity of varying the shadow blur from 20 down to 0. Notice that it switches all of a sudden to all blue at the end, where it should instead have an all red shadow rect on top. http://webstuff.nfshost.com/shadowblur.html

Looking around, it appears that the only browsers that support this faulty edge case are FireFox4 (not before 4 though), WebKit browsers that use CG (and also Skia, jamesr tells me).

My proposal is to:
1) Change the spec by stripping out this edge case paragraph.
2) Notify Firefox team that they should strip out this hack in their code for the edge case.
3) Remove the hack also from Skia.
4) File a bug against CG on this faulty behavior (just did that) and hope that it can be fixed in future releases.
5) In GraphicsContextCG, "fix" this faulty behavior for all OSes that don't this possible future CG fix (via Gestalt).
6) Tell philip/W3C to update his/the test at http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html / http://w3c-test.org/html/tests/approved/canvas/2d.shadow.enable.off.2.html
7) Remove the GraphicsContextCG "fix" in a few thousands years if/when we no longer need to support the broken CG.
Comment 1 James Robinson 2011-05-03 17:34:43 PDT
(In reply to comment #0)
> My proposal is to:
> 1) Change the spec by stripping out this edge case paragraph.
> 2) Notify Firefox team that they should strip out this hack in their code for the edge case.
> 3) Remove the hack also from Skia.
> 4) File a bug against CG on this faulty behavior (just did that) and hope that it can be fixed in future releases.
> 5) In GraphicsContextCG, "fix" this faulty behavior for all OSes that don't this possible future CG fix (via Gestalt).
> 6) Tell philip/W3C to update his/the test at http://philip.html5.org/tests/canvas/suite/tests/2d.shadow.enable.off.2.html / http://w3c-test.org/html/tests/approved/canvas/2d.shadow.enable.off.2.html
> 7) Remove the GraphicsContextCG "fix" in a few thousands years if/when we no longer need to support the broken CG.

Can you also start a thread on the WHATWG list explaining this proposal?  Other vendors might have input that could alter this plan.  This seems fine to me, however, unless we discover that there is some content that depends on the current behavior that we have to support.
Comment 2 Matthew Delaney 2012-01-26 12:16:04 PST
For reference, here's the thread. The current stance is to keep the spec as-is. 
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-May/031457.html
Comment 3 Dirk Schulze 2014-04-04 13:27:24 PDT
We do not have interoperable behavior here. Safari has a shadow at the beginning which disappears at the end. Same for Blink. Firefox just has an inset like shadow.
Comment 4 Dirk Schulze 2014-04-05 14:08:01 PDT
Ok, http://webstuff.nfshost.com/shadowblur.html definitely shows a weird behavior cross platform. It might better if the canvas spec describes better if the shadow is a separate drawing operation or belongs to the object that is drawn. Currently browsers are not interoperable on that.

However, the initial bug report is invalid. WebKit behaves as specified and does not draw the shadow if opacity == 0. It does not seem that the spec will change.