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

Re: [Public WebGL] Addition to WebGLContextLostEvent wrt extensions





On Fri, Apr 9, 2010 at 7:15 AM, Chris Marrin <cmarrin@apple.com> wrote:

On Apr 8, 2010, at 9:50 AM, Gregg Tavares wrote:

> Maybe this well help describe my concern.
>
> Imagine you had a i/o device API with a "device lost" and "device recovered" and you wrote code like this.
>
> f = device.openfile(...);
> somethingUnrelatedToDevice.addEventHandler("moreDataAvailableEvent", writeMoreData);
>
> function writeMoreData(data) {
>   f.write(data);
>   if (data.finished) {
>     f.closefile();
>   }
> }
>
> Now imagine while writing the data you get a "device lost" and a "device recovered". You've now written a bad file because you're missing some portion of the middle of the data.
>
> That's the model WebGLContextRestored seems to be providing. You get effectively random failure and random success instead of something more predictable  With the Resetable/Reset model you get random failure but never random success. You recover on your own terms, not some random terms.


I'm not sure what you mean. No matter what model you use, if you're not checking for errors while using an object, you will get incorrect results. In your example, if the machine were shutdown while writing a file, one of those f.write calls would return an error. You'd then know the written file is corrupt. When the device was restored, you'd destroy that file, open a new one and ask the provider for the data again. I don't see any way around this, regardless of the semantics of the API.

Am I misunderstanding the problem?

The problem I'm imaging is that a typical GL programmer will take old code that was like this

Do1000InitializationSteps();
RunMainLoop();

They'll change it to

Do1000IntializationStepsAsync(>
They don't check for every possible error.

During those 1000 steps they get WebGLContextLost and WebGLRestoreContext which they didn't bother to put handlers for.

By the time the code gets to runMainLoop everything seems fine but it's not.  Every resource created before WebGLContextLost is bad. They won't check for errors during the main loop because that's bad form for GL programs.  So, their app has a few textures missing or a few something else is not setup correctly but because behind the scenes the lost context was auto restored they have no idea what happened.

If there was no auto-restoring of the context then their program would fail for sure when they got to RunMainLoop and they'd fix the issue.
 

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




-----------------------------------------------------------
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: