[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Lost Context
- To: Vladimir Vukicevic <email@example.com>, public webgl <firstname.lastname@example.org>
- Subject: Re: [Public WebGL] Lost Context
- From: Gregg Tavares <email@example.com>
- Date: Sat, 13 Feb 2010 13:23:52 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1266096235; bh=E/xYEgs2onpBV8+tZIR7pvZFJPg=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Content-Type; b=nNZFD7TFi6TqSNWcEvsTXDGB2dmZ/SoSWhjZm91IvUcuRGEqc+zoWJsW7L0aIYAp1 8w6sCakgiWHmFYcChIYrA==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:date:message-id:subject:from:to: content-type:x-system-of-record; b=A1r2kRaeG8sfMXRQB82fcdZ7KJOZlpDO/PT5XmFBUwam9G95XCd+7wN3feTUxAIac qOfSThXIaWFJvMBDAan5Q==
- In-reply-to: <4B76F7D4.firstname.lastname@example.org>
- References: <email@example.com> <4B76F7D4.firstname.lastname@example.org>
- Sender: email@example.com
On Sat, Feb 13, 2010 at 11:04 AM, Vladimir Vukicevic <firstname.lastname@example.org>
I like this suggestion, but there's a problem with the recovery mechanism -- you can't just call getContext again, because getContext is specified to give you back the same context object for any previous call for "webgl"; and that context is no longer valid.
On 2/12/2010 10:10 PM, Gregg Tavares wrote:
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")
So, perhaps this event should be called a Context Reset event, where you lose all resources/state, but the WebGL implementation ensures that the same context object is valid again?
That's one idea but wouldn't solve the issue mentioned before that if
you get the event halfway through that loop, half of your resources are
okay and half are not. From the example above,
ctx.bindTexture(ctx.TEXTURE_2D, textures); // would fail
ctx.bindTexture(ctx.TEXTURE_2D, textures); // would not fail
It seems like it would be good if everything fails after a context lost event until you are ready to deal with it.
Another solution is you could get Context Lost and everything fails until you call context.reset()
The issue is also that the implementation has to track which resources are good and which are bad. Since each resource is already associated with a context it seems easier to just say that lost context is bad and you need a new context. We could change the spec so calling canvas.getContext("webgl") does not return the same context if you've lost the context. Then if you tried to use a resources from the original context with the new context it would be obvious why it's failing.
newContext.bindTexture(gl.TEXTURE_2D, oldTexture); // EXCEPTION object not from this context?
On the other hand, the context.reset() way could just as easily hide the fact that underneath it's creating a new actually GL context and that all your old resources, being associated with the old context, are invalid. I guess the new context seems cleaner to me but either way works.