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

Re: [Public WebGL] Lost Context

On Mon, Feb 15, 2010 at 10:23 AM, Chris Marrin <cmarrin@apple.com> wrote:

On Feb 13, 2010, at 3:57 PM, Vladimir Vukicevic wrote:

>> ...I'll bring up another issue which I'm sure no one wants to discuss but, passing all this lost context stuff down to _javascript_ sure seems far removed from anything else in HTML. Imagine if <img>, <video>, <audio>, <canvas2d> etc all needed _javascript_ to manually deal with lost-context.
> Yep, it's not that we don't want to discuss it, it's more that there's really no sane way around it -- the only alternative is to keep a copy of every user resource.  It would be better if the underlying GL/D3D impl would take care of all of that, and I'd guess that we'll get there eventually..

Let's not get too hasty here, saying that there is no way to automatically recover from a context loss. First of all, what does context loss mean? Does it mean that some or all of the resources (textures, VBOs, etc.) are lost, or is the GL state lost as well?
If it's the former then it's just a matter of keeping a shadow copy of all the buffer data. Often the source data is from an HTML image, which is cached anyway.

It's both resources and state but if we wanted to recover we could shadow the state as well.
What we can't recover is framebuffers and renderbuffers.

Just throwing this out there but one possibility is to make that an option of the context. You could request a context that shadows. This could actually be done easily in _javascript_ but I suspect shadowing the state would be too slow in _javascript_.

Actually this brings up a new problem. I don't know what all the implementations do but I suspect some of them are using an FBO to store the contents of the canvas and they never copy that store to CPU memory except on toDataURL or ctx2d.drawImage.  But that brings up the issue that a lost-context can loose the FBO state which isn't what's supposed to happen for the <canvas> tag. Once you've drawn something it's supposed to be permanent. I guess we can ask the HTML5 guys to change the <canvas> spec to say the canvas can lose its contents at any time.


I know it would incur extra work and storage overhead to do automatic recovery. But let's not discard the notion before analyzing it some more. This is the web and web authors expect that lots of the background work will be done for them.


You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: