[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 3:15 AM, Cedric Vivier <cedricv@neonux.com> wrote:
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.

This is NOT how _javascript_ works. Events are always asynchronous AFAIK. _javascript_ does not support being "interrupted" by an event. Events are not delivered until _javascript_ exits.
 

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,