[Public WebGL] (summarizing) Canvas.getContext error handling

Glenn Maynard [email protected]
Sun May 1 21:06:06 PDT 2011

On Sun, May 1, 2011 at 11:40 PM, Cedric Vivier <[email protected]> wrote:
> The minor change necessary in the Canvas Spec is the addition of "or
> null if the context could not be created" at step 6 :
> "6. Return a new object for contextId or null if the context could not
> be created, as defined by the specification given for contextId's
> entry in the WHATWG Wiki CanvasContexts page."

It needs a bit more than that.  In the failure case, it should
probably leave the primary context unchanged, and step 5 would need to
be made clear (for example, "has already been invoked on this element
for the same contextId and returned successfully ...").

That's not hard, by any means--someone just needs to convince upstream
that a change is needed.

> Do you imply that moreover changing the Canvas spec and interface we'd
> also need to change every debugger out there? ;-)

I'm saying that we should report errors using the standard mechanism
in the language; use exceptions as they're meant to be used.  What
you're effectively saying is that the API should avoid exceptions and
use error-return-value style (C-style) error reporting because
debuggers aren't yet up to snuff.  I disagree strongly with that: we
should use exceptions normally, and trust that the tools will catch up
in due time.

> Yes, we are aware of this. Hence why we are discussing the two
> possible options with regards to the getContext spec :
> Option 1 - add possibility or returning null at step 6 - doesn't break
> current semantics/interface, shouldn't be much trouble to get this
> upstream hopefully.
> Option 2 - add possibility of throwing an exception - breaks current
> semantics/interface, you attempted to push this upstream already and
> it was not a welcome change.

No, upstream was opposed to the idea of getContext reporting the
reason for the error at all.  This applies to either approach.  He
argued (briefly--I didn't press the issue, so I don't know how
strongly he feels about this) that the reason for the context failing
shouldn't even be exposed to scripts.

I'd recommend that somebody talk with him (Ian Hickson) directly about
this.  If you can convince him that an error reporting mechanism is
needed in the first place, his opinion on what method to use will be
valuable.  (I'd prefer somebody directly involved speak with him,
since it's an extra level of indirection for me to do it.)

Glenn Maynard
You are currently subscribed to [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl

More information about the public_webgl mailing list