[Public WebGL] How to check for WebGL support

Vangelis Kokkevis [email protected]
Thu May 19 10:37:09 PDT 2011

A recurring issue with sites that want to use WebGL is that there's
currently no good light-weight way to check whether WebGL is supported in a
particular client. We have a couple of mechanisms in place but they all have

1. Statically check for window.WebGLRenderingContext :  This will return
false positives, e.g. when running on blacklisted configurations, when WebGL
is explicitly disabled via some user pref, etc.
2. Create a WebGL context and inspect the result : Creating a context is
expensive (slow) and when you only need to know whether WebGL is supported
the resulting context isn't really needed.

One possible solution would be to define window.WebGLRenderingContext only
if both the browser supports WebGL and all the blacklist / user-pref / etc.
 tests succeed.  Current pages will have to be tweaked to report a more
generic "WebGL is not supported on your configuration" type of message
rather than "Your browser does not support WebGL".  If they really need to
know why it's not supported they can go one step further and try to create
the WebGL context and decipher any context creation error.

Obviously there will still be some false positives with this mechanism but
they will hopefully be rare.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110519/82b63fa3/attachment.html>

More information about the public_webgl mailing list