[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] Lost Context
- To: public webgl <public_webgl@khronos.org>
- Subject: [Public WebGL] Lost Context
- From: Gregg Tavares <gman@google.com>
- Date: Fri, 12 Feb 2010 22:10:28 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1266041432; bh=t5URSzr1iH3gb7RxGhBA5ikcw3s=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=gFAkJXUoGxiCDaSyRw08FsegIEbJB7Sn/qVbHkkIvbw/T7ysiudAk3jVgcRhf6NoO eu/0bAnORCqXfWc5a0YzQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:date:message-id:subject:from:to:content-type:x-system-of-record; b=IODi1FO1JFpARSbeloPXGBkvsanZfRW8CnTQEj68vxI53qW1yYxiult9BZxf+8CNg mfgEG3EitPradcsEAVpaw==
- Sender: owner-public_webgl@khronos.org
There was some discussion today about the current specification of how WebGL handles a lost context.
It seems like if you lose a context there is no real recovery and that you really need to start with a fresh context.
So, as a suggestion, what if the spec changed from this
interface WebGLResourceLostEvent : Event {
readonly attribute WebGLObject resource;
readonly attribute WebGLRenderingContext context;
void initWebGLResourceLostEvent(in DOMString type,
in boolean canBubble,
in boolean cancelable,
in WebGLObject resource,
in WebGLRenderingContext context);
};
to this
interface WebGLResourceLostEvent : Event {
readonly attribute WebGLRenderingContext context;
void initWebGLResourceLostEvent(in DOMString type,
in boolean canBubble,
in boolean cancelable,
in WebGLRenderingContext context);
};
Removing the "resource" argument, and that if you get one of these events the context in question is no longer valid. Every call to anything in that context from that point on will have no effect and context.getError will constantly return context.LOST_CONTEXT
To recover you have to create a new context by calling canvas.getContext("webgl")
As for an example of why it seems like this is necessary, imagine the following code.
var textures = [];
for (var ii = 0; ii < 100; ++ii) {
var tex = ctx.createTexture();
textures[ii] = tex;
ctx.bindTexture(ctx.TEXTURE_2D, tex);
ctx.texImage2D(ctx.TEXTURE_2D, 0, someCollectionOfImgTags[ii]);
}
Now imagine as this code is half way finished executing the context is lost (user pressed sleep on his phone). When the system comes back, if the code can continue it will end up in this strange state of the first set of resources gone and the second set of resources valid and no really easy to program around it.