[whatwg] Canvas API: What should happen if non-finite floats are used

Oliver Hunt oliver at apple.com
Wed Sep 8 11:22:32 PDT 2010


On Sep 8, 2010, at 11:00 AM, Boris Zbarsky wrote:

> On 9/8/10 12:45 PM, Oliver Hunt wrote:
>> I suggested this behaviour a long time ago after running into yet
>> another piece of code that hit this case in webkit (back when the
>> spec said to throw an exception) yet firefox and opera did not throw.
>> In some cases firefox does throw, and in others it doesn't (or maybe
>> didn't? has ffx behaviour changed?)
> 
> Gecko behavior for lineTo and most other canvas methods I see has been to throw since late 2006, and shipped with the initial release of Firefox 3.0.  At the time, the change was also backported to the Firefox 1.5 and Firefox 2 branches.
> 
>> and we came to the conclusion that as much as possible the canvas should silently ignore
>> NaN/Infinite values.
> 
> Well, except that leads to incorrect rendering, as I said.  Was this discussion public, perchance?

I can see a number of canvas discussions in late 2007/early 2008 on the whatwg list, so i presume that covers some of it.

It also only leads to incorrect rendering if the behaviour if it's unexpected.

One old case that failed in the presence of exceptions was the old canvex demo at http://canvex.lazyilluminati.com/83/play.xhtml - this was one of the first cases i saw after trying to make webkit's implementation conform to the (older) spec by throwing exceptions on non-finite values we had many canvas using sites break so had to stop throwing.

It seems to work these days but a quick scan of the minified source seemed to indicate that they now put try/catch around every use of canvas is now wrapped in try/catch

--Oliver





More information about the whatwg mailing list