[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] getContext error handling

On Sat, Apr 9, 2011 at 18:25, Glenn Maynard <glenn@zewt.org> wrote:
> For what it's worth, this is how I'd describe it:
>> 2.1 The canvas Element
>> When the getContext method of a canvas [CANVAS] element is to return a new
>> object[2] for the contextId webgl, the user agent must run the following
>> steps:
>> 1. Create a new WebGLRenderingContext object and associated drawing
>> buffer.
>> 2. If an error is encountered creating these objects, fire a simple event
>> named "webglcontextcreationerror" at the canvas element, clear the primary
>> context of the canvas, return null and terminate these steps.
>> 3. Return the WebGLRenderingContext.
> This aligns with the wording used by the getContext ([3]) and 2d canvas[4].
> It omits all mention of "first" and "subsequent calls", since
> canvas.getContext already describes that case.  HTML defines "fire a simple
> event"[5], which also specifies that the event does not bubble and is not
> cancelable.

Nice, this makes even more sense to describe it here indeed.
We should take this opportunity to define all WebGL events as simple
events as well.

> The "clear the primary context" part in step 2 shouldn't be necessary; the
> getContext algorithm in the HTML should specify this.

I think it is indeed unnecessary and already specified at [1].
WebGL's getContext behavior described above would be the step 6 of
canvas's getContext [1], therefore according to step 3 of [1] it is
not possible to get to WebGL's getContext when there is already a
primary context.

> I'll email whatwg asking about this, since getContext seems to assume that "Return a new
> object for contextId" can never fail.

IMHO there is no such assumption and returning null is valid since
step 6 specifically refers to the requested context's specification :
"Return a new object for contextId, as defined by the specification
given for contextId's entry in the WHATWG Wiki CanvasContexts page."

However this might make sense to require for null rather than an
exception with any context when an error occurred at creation.

[1] : http://www.w3.org/TR/html5/the-canvas-element.html#dom-canvas-getcontext


You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl