[whatwg] [canvas] Proposal for supportsContext

Paul Irish paul.irish at gmail.com
Mon Sep 10 16:08:28 PDT 2012


On Mon, Sep 10, 2012 at 3:14 PM, Glenn Maynard <glenn at zewt.org> wrote:
>
> (By the way, I'm not sure about it being "bad practice" to create a context
> in advance.  It's just standard feature testing, which is exactly how
> JavaScript developers have been taught to detect features.
>


Indeed, js developers are guided towards feature detection, and rightly so.
But which detect to use is a bit of cat 'n mouse and implementors don't
play by the same rules here.

As Mike Taylor pointed out, Modernizr used to create a context because
checking !!window.WebGLRenderingContext is completely unreliable. But the
Mozilla and Chrome GPU teams persuaded us to avoid the up-front context
creation.


On Mon, Sep 10, 2012 at 2:44 PM, Tobie Langel <tobie.langel at gmail.com>
 wrote:

> Only expose the API when you can create the context.

This is the ideal and most expected feature detect typically, though in
WebGL's case we share a getContext method with 2d and opera-2dgame, so
hiding the constructor global comes in second place. So far, Chrome and
Firefox weren't excited about this approach.



It's extremely important that we have feature detection techniques that we
can trust the result of, across implementations. I'm a big +1 for
supportsContext and as an API, it seems to introduce the ability with the
least amount of collateral damage.

_
Paul Irish, Lead Modernizr Dev



More information about the whatwg mailing list