On Tue, Apr 12, 2011 at 2:21 AM, Boris Zbarsky <bzbar...@mit.edu> wrote: > On 4/12/11 12:06 AM, Ian Hickson wrote: >>> >>> Now, that's a problem for WebGL, because it's not possible to tell in >>> advance whether the underlying rendering context can be created. >> >> It would be helpful if someone could explain what conditions could lead to >> a situation where getContext() could fail to return a WebGL context. > > In at least Gecko's implementation, creating of an actual GLContext to back > the WebGL context could fail. Unfortunately, this can happen any time too > many WebGL contexts are live; what "too many" means depends on the exact GPU > resources available. > > I think we consider the fact that part a quality of implementation issue, > though we haven't figured out how to do the "high quality" think here yet. > ;) > >> Is it something the author can do anything about > > Still in Gecko's case, drop references to some GL contexts and canvases, and > hope for GC to happen.....
In Chromium the same basic issue is present. We are close to being able to forcibly evict "old" OpenGL contexts in response, so that creation of the current one could proceed. In this case the author wouldn't need to do anything. There are two more cases I can think of. The first is when the graphics card or driver version is blacklisted. In this case getContext() will always return null, and there's nothing the developer can do. Currently this would be reported via webglcontextcreationerror. We could consider throwing an exception containing the detail message. The second is if the graphics card is in a powered-off state when the app calls Canvas.getContext("webgl") -- for example, if a notebook is awakening from sleep. In this case a good quality WebGL implementation would like to notify the app when the graphics card is available. In order for this to work, WebGL would actually need to return a non-null WebGLRenderingContext, but immediately dispatch a webglcontextlost event to the canvas. To sum up, in general I think that whenever getContext("webgl") returns null, it's unrecoverable in a high quality WebGL implementation. -Ken