[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Re: [whatwg] Canvas.getContext error handling

So I just want to throw this out there but what if we weren't limited by the current design and started from scratch? I'm not saying we should start from scratch, rather I think we should explore other solutions and see where they take us.

For example, starting up WebGL can be very slow. Because the API is currently synchronous this pretty much freezes the browser or at least the page it's on until that startup is finished. While always returning a non-NULL webgl object and handling webglcontextlost and/or webglcontextcreationerror would solve that problem they seem like a really around about way to go at it.

function handleContextLost(event) {
   event.preventDefault(true);  // If I don't do this then I'll never get a usable context

function handleContextRestored(event) {

canvas.addEventListenter("webglcontextlost", handleContextLost, ...);
canvas.addEventListenter("webglcontextrestored", handleContextRestored, ...);
gl = canvas.getContext("webgl");
return;  // because I can't actually run until I get webglcontextrestored

Maybe that makes sense. Maybe not? How about more XHR like?

gl = canvas.getContext("webgl");

I guess it's 6 of one, half dozen of another. It just seems in either case it's pretty convoluted on how you have to use it. I wish I could think of a non-convoluted way :-(