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

Re: [Public WebGL] Addition to WebGLContextLostEvent wrt extensions





On Thu, Apr 22, 2010 at 3:41 PM, Chris Marrin <cmarrin@apple.com> wrote:

On Apr 22, 2010, at 10:30 AM, Gregg Tavares wrote:

> So I worked through some sample code using WebGLContextRestored and convinced myself my fears were unfounded. Thank you for being patient with me.

Wait. I need context. Our current proposal has a WebGLContextRestorable event and a restore() method (replace restore with reset as needed). Is that your assumption, too?


No need for restore() I think.

What's needed is WebGLEventContextLost and WebGLEventContextRestored with the detail that WebGL will fail all calls until the WebGLEventContextRestored is delivered (ie, the function registered for it is called)

In otherwords

ctx = canvas.getContext("webgl");
cavnas.addEventListener("webGLEventContextRestored", handleRestore);

function handleRestore() {
  // At this point ctx is usable and accesses the restored context, not the lost context.
}

That means that for example if I do this

var textures[];
for (var ii = 0; ii < 1000; ++ii) {
  textures[ii] = ctx.createTexture();
}

And while that loop is running the OpenGL context is lost (say at ii = 123) and then restored (say at ii = 456) WebGL will still fail all calls after ii = 456 because the WebGLEventContextRestored has not yet been handled (_javascript_ being synchronous)

The other detail is that if no handler is registered then WebGL will fail forever after a lost context.


 
-----
~Chris
cmarrin@apple.com