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

Oliver Hunt oliver at apple.com
Wed Sep 8 10:33:37 PDT 2010


On Sep 8, 2010, at 10:20 AM, Eric Uhrhane wrote:

> On Wed, Sep 8, 2010 at 9:45 AM, Oliver Hunt <oliver at apple.com> wrote:
>> The problem with throwing an exception is that it's fairly common for code to end up accidentally producing a NaN or Infinite value, and throwing an exception would prevent all subsequent drawing from occurring.
> 
> I believe that was the point: you throw an exception, the bug becomes
> obvious, and you fix it.  Without the exception, you draw the wrong
> thing, and it's much harder to find the problem.
In a lot of cases all you want to do is ignore NaN and Infinite values, otherwise you basically have to prepend every call to canvas with NaN and Infinity checks if you're computing values unless you can absolutely guarantee your values won't have gone nuts at any point in the computation -- otherwise you're going to get reports that occasionally your content breaks but with no repro case (typical users will not be seeing error messages, it just "doesn't work").

Additionally there is content that depends on the non-throwing behaviour, in webkit we had to drop the exceptions that we threw due to content that worked in firefox because of the absence of exceptions.

In the ended we spec'd these values as being ignored so that there was some degree of consistency through the API (and because the various UAs that support canvas would through on non-finite values in differing functions).

--Oliver




More information about the whatwg mailing list