[whatwg] Canvas.getContext error handling

Glenn Maynard glenn at zewt.org
Tue Apr 12 16:32:45 PDT 2011

Based on some discussion[1], it looks like a clean way to handle the
"permanent failure" case is: If the GPU is blacklisted, or any other
permanent error occurs, treat "webgl" as an unsupported context.  This means
instead of WebGL's context creation algorithm executing and returning null,
it would never be run at all; instead, step 2 of getContext[2] would return

For transient errors, eg. too many open contexts, return a WebGL context in
the "lost" state as Kenneth described.

It was mentioned that the GPU blacklist can change as the browser runs.
That's supported with this method, since whether a context type is
"supported" or not can change over time.

Are there any cases where this wouldn't work?

(I'm not sure if or how webglcontextcreationerror fits in this.  It would
either go away entirely, or be wedged between steps 1 and 2 of getContext; I
don't know how WebGL would specify that.)

[1] http://krijnhoetmer.nl/irc-logs/whatwg/20110413#l-77

Glenn Maynard

More information about the whatwg mailing list