Re: [whatwg] Challenging canvas.supportsContext

On the Modernizr side, an old version did indeed create a context for
feature detection. For the past two years we have advocated the soft
`"WebGLRenderingContext" in window` test instead. There, of course, is some
gap between the results of that detect and how successful a getContext call
will be, but I don't have data those false positive rates.

A use case of a Modernizr user is to detect WebGL and show a browser prompt
if it's not detected.  From my understanding nearly no developer re-use the
same context for both detection and use.

I asked mrdoob, developer of three.js if supportsContext would be useful to
the project.. He said they currently create 2 webgl contexts "because,
API-wise is not easy to reuse the context that you created for checking if
it was available. Well, it's not pretty, at least"

I know the Chrome Web Store had a usecase for detection without context
creation: they wanted to not show apps in the marketplace that couldn't run
on the user's machine.

I agree that supportsContext is only useful if it's more accurate that
!!window.WebGLRenderingContext.



On Wed, Jun 19, 2013 at 2:05 PM, James Robinson <jamesr@google.com> wrote:

> On Wed, Jun 19, 2013 at 1:22 PM, Brandon Benvie <bbenvie@mozilla.com>
> wrote:
>
> > On 6/19/2013 12:46 PM, Boris Zbarsky wrote:
> >
> >> On 6/19/13 3:43 PM, Kenneth Russell wrote:
> >>
> >>> Accurate feature detection in libraries like Modernizr was mentioned
> >>> as a key use case:
> >>>
> >>> http://lists.whatwg.org/**pipermail/whatwg-whatwg.org/**
> >>> 2012-September/037249.html<
> http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-September/037249.html
> >
> >>>
> >>
> >> Right, this is the use case that's not really making sense to me. The
> >> fact that Modernizr was doing this _eagerly_ sounds like a bug in
> Modernizr
> >> to me...
> >>
> >
> > The point of using Modernizr or something like it is to detect
> > availability of features on page load, and then conditionally load
> > polyfills/alternate fallback implementations. It specifically does need
> to
> > do eager detection to be useful. It can't wait until the first usage to
> do
> > feature detection; it needs to be done up front when preparing
> dependencies
> > for the main application.
> >
>
> What would a page using Modernizr (or other library) to feature detect
> WebGL do if the supportsContext('webgl') call succeeds but the later
> getContext('webgl') call fails?
>
> I'm also failing to see the utility of the supportsContext() call.  It's
> impossible for a browser to promise that supportsContext('webgl') implies
> that getContext('webgl') will succeed without doing all of the expensive
> work, so any correctly authored page will have to handle a
> getContext('webgl') failure anyway.
>
> - James
>
>
> > This is also why Modernizr provides a custom build tool. It allows for
> > users to only do the feature detection on features they know they need to
> > care about, because each check has some cost that needs to be paid early
> on
> > in a page load.
> >
>

Received on Wednesday, 19 June 2013 21:28:35 UTC