Re: [whatwg] Challenging canvas.supportsContext

2013-06-19 Thread Paul Irish
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  wrote:

> On Wed, Jun 19, 2013 at 1:22 PM, Brandon Benvie 
> 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.
> >
>


Re: [whatwg] [canvas] Proposal for supportsContext

2012-09-10 Thread Paul Irish
On Mon, Sep 10, 2012 at 3:14 PM, Glenn Maynard  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 
 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


Re: [whatwg] Bandwidth media queries

2012-05-20 Thread Paul Irish
Since no one mentioned it, I just wanted to make sure this thread is aware
of the Network Information API [1], which provides
navigator.connection.bandwidth

It's been recently implemented (to some degree) in both Mozilla [2] and
Webkit [3].

[1] http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/index.html
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=677166#c42
[3] http://trac.webkit.org/changeset/112815