W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2011

[whatwg] Canvas.getContext error handling

From: Cedric Vivier <cedricv@neonux.com>
Date: Thu, 14 Apr 2011 04:25:36 +0800
Message-ID: <BANLkTinq5jyZN_sCZmh7hT0LF1yqDa7wCg@mail.gmail.com>
On Wed, Apr 13, 2011 at 05:16, Kenneth Russell <kbr at google.com> wrote:
> (...)
> To sum up, in general I think that whenever getContext("webgl")
> returns null, it's unrecoverable in a high quality WebGL
> implementation.

Makes sense.
Applications could detect all possible context creation failure
scenarios with something like this :


var gl = canvas.getContext("webgl");
if (!gl) {
    if (!window.WebGLRenderingContext) {
       // Your browser does not support WebGL. Please upgrade your browser.
    } else {
       // WebGL could not be initialized on your setup. Please check
that your GPU is supported and/or upgrade your drivers.
    }
}
if (gl.isContextLost()) {
    // Not enough resources to initialize WebGL. Please try closing
tabs/programs...
    // (an application can, but is not required to, listen to
webglcontextlost and use statusMessage to give more information)
}


For the use case of detecting context restoration error, we could
possibly add an 'isRestorable' boolean to webglcontextlost event to
signal the app when restoration failed (and/or won't ever happen).


Therefore I believe we can get rid of webglcontextcreationerror
entirely, and we do not need to throw an exception either.


Regards,
Received on Wednesday, 13 April 2011 13:25:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:03 GMT