[Public WebGL] What should getContextAttributes return after the context has been lost?
Wed Apr 4 15:39:01 PDT 2012
On Wed, Apr 4, 2012 at 4:20 PM, Boris Zbarsky <[email protected]> wrote:
> The IDL says:
> WebGLContextAttributes getContextAttributes();
> This is not a method that has explicit context lost handling, so we end up
> in the 6-step algorithm in https://www.khronos.org/**
> We reach step 5 with "use default value" set to true.
> We return nothing in step 5.1, since the return value is not a nullable
> type or 'any'.
> Step 5.2 says "Terminate this algorithm without calling the method
> implementation". What does that mean? What's the actual return value? Is
> a JS exception thrown? If so, which one?
> I'm guessing the return type in this case should just be
Since it's easy to keep this information around after a context loss, I
think it'd be better for this function to have explicit context lost
handling, and always return the context attributes. Not returning null
when we don't have to eliminates the user bugs that will be caused by
rarely returning null. People don't write:
var attr = ctx.getContextAttributes()
if(attr != null && attr.alpha)
they simply say "if(ctx.getContextAttributes().alpha)". Never returning
null eliminates an entire small category of bugs.
There may be other uses of being able to grab the context attributes after
a context loss, too, eg. someCanvas.getContext("webgl",
There are similar issues with various creation functions and whatnot.
For functions like createTexture, I think they should behave as described
If that's done, those functions would have explicit context loss handling,
and wouldn't have nullable return values.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the public_webgl