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

Re: [Public WebGL] Firefox 4 and blacklist reporting



On Wed, Mar 30, 2011 at 17:15, Gregg Tavares (wrk) <gman@google.com> wrote:
> Maybe we should revisit that part of the spec.

Yes, the current text is misleading :
"Later, at the normal event delivery time, this event is delivered
with the details of the failure. If the HTMLCanvasElement is listening
for this event, it will be delivered whenever getContext() returns
null."

There's no later, the event listener (if any) will be executed before
getContext returns, which allows to capture the additional
information. Also I don't think we require the canvas itself to listen
to the event.

I propose to replace above sentences and the whole
webglcontextcreationerror paragraph with :

"This event is dispatched from the HTMLCanvasElement by getContext()
when some error occurs during that call.
The event allows to collect details about the failure that will result
in getContext() returning null."


Example usage :

function getContext(errorCallbackWithReason) {
    var context;
    var gotReason;
    if (!window.WebGLRenderingContext) {
        errorCallbackWithReason("WebGL is not implemented by this browser");
        return null;
    }
    try {  // need a try here because of Firefox 4
        canvas.addEventListener("webglcontextcreationerror", function
onContextCreationError(event) {
             gotReason = true;
             errorCallbackWithReason(event.statusMessage);
        }, false);
        context = canvas.getContext("webgl");
   } catch (e) {}
   if (!context && !gotReason) {
        errorCallbackWithReason("Failed to create context for an
unknown reason".)
   }
   return null;
}


Cheers,
-----------------------------------------------------------
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
-----------------------------------------------------------