W3C home > Mailing lists > Public > public-webrtc@w3.org > November 2013

Re: constraints vs attributes

From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Wed, 13 Nov 2013 15:51:10 -0500
Message-ID: <5283E63E.5050407@mozilla.com>
To: Jim Barnett <Jim.Barnett@genesyslab.com>, "public-webrtc@w3.org" <public-webrtc@w3.org>
On 11/12/13 2:38 AM, Jim Barnett wrote:
> I think that the Constrainable interface is based on three largely 
> orthogonal features that distinguish it from attributes:
> 1.The application can query the set of legal values for the property. 
>  This is useful when the set of values is non-obvious, particularly 
> when the set of values can vary from device to device.  (Supported 
> screen resolutions would be an example.)
> 2.The application can request a range of values, allowing the UA to 
> choose within that range.
> 3.The UA may ignore the application’s request for certain values if it 
> cannot satisfy it (and this is not treated as an error)
> I think that Constrainable is appropriate when any of these three 
> conditions holds.  Attributes are suitable when:
> 1.There is no need to query the set of legal values because all 
> devices support the same ones.
> 2.The app needs only to specify a specific value (or ranges don’t make 
> sense).
> 3.The UA must accept the value the app specifies (as long as it 
> matches the attribute’s type).

I think this is a false choice. At least it should be: constraints vs. 
dictionaries vs. attributes.

In fact, I would argue #1, #2 and #3 (the first ones) are all features 
of using webidl dictionaries, not constraints.

I find the distinguishing feature of constraints to be the functionality 
it adds beyond what's achieved through mere convention of 

 1. The application can select from a collection of undisclosed yet
    discrete property-holding choices, based on need (mandatory) and
    ordered preference (optional).

In other words, I find constraints useful for describing recipes for 
picking objects.

Specifically, I would not use constraints in an API unless we're 
operating on a collection of choices (you call them 'devices'), because 
of the complexity, confusion and implementation cost this adds.

An example of cost:

The PeerConnection settings, OfferToReceiveAudio, OfferToReceiveVideo 
etc. fail my constraint-test, not because they are booleans, but because 
we're not picking from a collection of discrete property-holding objects 
inside a PeerConnection (an architecture I hope one would not choose 
without external reasons, because it complicates the API for internal 

The implementation cost is that the spec requires me to "preserve the 
order of the optional keys", which is a hardship as I cannot flatten 
this structure of simple settings inside the implementation (when even 
the mandatory/optional state falls away after settings are set). 
Instead, I must carry this state around for no reason - there's no 
algorithm and no collection of objects to re-apply these "rules" to - 
and deal with additional rules governing how to pass around and 
manipulate these things which are of no benefit.

The confusion and complexity cost is that this is harder than it needs 
to be.

> So things with Boolean values should be attributes (this is the 
> opposite of what I said on the call). So should things whose values 
> can be any string or any int.

.: Jan-Ivar :.
Received on Wednesday, 13 November 2013 20:51:38 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:36 UTC