[whatwg] Canvas.getContext error handling
Cedric Vivier
cedricv at neonux.com
Wed Apr 13 13:25:36 PDT 2011
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,
More information about the whatwg
mailing list