Skip to content

Commit

Permalink
Move applyConstraints algorithm off main thread, and handle errors co…
Browse files Browse the repository at this point in the history
…rrectly.
  • Loading branch information
jan-ivar committed Aug 27, 2018
1 parent fea631b commit ea35f26
Showing 1 changed file with 72 additions and 49 deletions.
121 changes: 72 additions & 49 deletions getusermedia.html
Expand Up @@ -3550,18 +3550,11 @@ <h2>Methods</h2>
verifying that at least one settings dictionary
exists that satisfies the constraints.</p>
<p>If <var>candidateSet</var> is the empty set, let
<var>constraint</var> be any required constraint
<var>failedConstraint</var> be any required constraint
whose fitness distance was infinity for all settings
dictionaries examined while executing the
<a>SelectSettings</a> algorithm, let
<var>message</var> be either <code>undefined</code>
or an informative human-readable message, and
<a>reject</a> <var>p</var> with a new
<code><a>OverconstrainedError</a></code> created by
calling
<code>OverconstrainedError(<var>constraint</var>,
<var>message</var>)</code>, then abort these
steps.</p>
<a>SelectSettings</a> algorithm, and jump to the step
labeled <em>Constraint Failure</em> below.</p>
<p class="fingerprint">This error gives information
about what the underlying device is not capable of
producing, before the user has given any
Expand Down Expand Up @@ -3654,7 +3647,9 @@ <h2>Methods</h2>
<li>
<p>Run the <a>ApplyConstraints algorithm</a> on all
tracks in <var>stream</var> with the appropriate
constraints.</p>
constraints. Should this fail, let <var>failedConstraint</var>
be the result of the algorithm that failed, and jump to
the step labeled <em>Constraint Failure</em> below..</p>
</li>
<li>
<p><a>Resolve</a> <var>p</var> with <var>stream</var> and
Expand All @@ -3666,6 +3661,14 @@ <h2>Methods</h2>
object whose <code><a>name</a></code> attribute has the
value <code>NotAllowedError</code>.</p>
</li>
<li>
<p><em>Constraint Failure</em>: Let <var>message</var> be
either <code>undefined</code> or an informative
human-readable message, and then <a>reject</a> <var>p</var>
with a new <code>OverconstrainedError</code> created by
calling <code>OverconstrainedError(<var>failedConstraint</var>,
<var>message</var>)</code>.</p>
</li>
</ol>
</li>
<li>
Expand Down Expand Up @@ -4127,8 +4130,47 @@ <h2>Methods</h2>
</dd>
<dt><code>applyConstraints</code></dt>
<dd>
<p>When <dfn>applyConstraints()</dfn> is called, it runs the
<a>applyConstraints algorithm</a> on the object.</p>
<p>When the <dfn>applyConstraints()</dfn> method is invoked, the
User Agent MUST run the following steps:</p>
<ol>
<li>
<p>Let <var>object</var> be the object on which this method was invoked.</p>
</li>
<li>
<p>Let <var>newConstraints</var> be the argument to this
method.</p>
</li>
<li>
<p>Let <var>p</var> be a new promise.</p>
</li>
<li>
<p>Run the following steps in parallel:</p>
<ol>
<li>
<p>Let <var>failedConstraint</var> be the result of
running the <a>applyConstraints algorithm</a> with
<var>newConstraints</var> as the argument.</p>
</li>
<li>
<p>If <var>failedConstraint</var> is <code>undefined</code>,
<a>resolve</a> <var>p</var> with <code>undefined</code>,
and abort these steps.
</li>
<li>
Let <var>message</var> be either
<code>undefined</code> or an informative human-readable
message, <a>reject</a> <var>p</var> with a new
<code>OverconstrainedError</code> created by calling
<code>OverconstrainedError(<var>failedConstraint</var>,
<var>message</var>)</code>, and abort these steps. The
existing constraints remain in effect in this case.</p>
</li>
</ol>
</li>
<li>
<p>Return <var>p</var>.</p>
</li>
</ol>
<p>The <a>applyConstraints algorithm</a> for applying constraints
is stated below. Here are some preliminary definitions that are
used in the statement of the algorithm:</p>
Expand Down Expand Up @@ -4274,48 +4316,29 @@ <h2>Methods</h2>
set to <code>"none"</code> over <code>"crop-and-scale"</code>.</p>
</li>
</ol>
<p>When the <dfn>applyConstraints algorithm</dfn> is called, the
User Agent MUST run the following steps:</p>
<p>To apply the <dfn>applyConstraints algorithm</dfn> to an
<var>object</var>, given <var>newConstraints</var> as an argument,
the User Agent MUST run the following steps:</p>
<ol>
<li>
<p>Let <var>p</var> be a new promise.</p>
<p>Let <var>successfulSettings</var> be the result of
running the <a>SelectSettings</a> algorithm with
<var>newConstraints</var> as the constraint set.</p>
</li>
<li>
<p>Let <var>newConstraints</var> be the argument to this
function.</p>
<p>If <var>successfulSettings</var> is
<code>undefined</code>, let <var>failedConstraint</var>
be any required constraint whose fitness distance was
infinity for all settings dictionaries examined while
executing the <a>SelectSettings</a> algorithm, return
<var>failedConstraint</var>, and abort these steps.</p>
</li>
<li>
<p>Run the following steps in parallel:</p>
<ol>
<li>
<p>Let <var>successfulSettings</var> be the result of
running the <a>SelectSettings</a> algorithm with
<var>newConstraints</var> as the constraint set.</p>
</li>
<li>
<p>If <var>successfulSettings</var> is
<code>undefined</code>, let <var>failedConstraint</var>
be any required constraint whose fitness distance was
infinity for all settings dictionaries examined while
executing the <a>SelectSettings</a>
algorithm, let <var>message</var> be either
<code>undefined</code> or an informative human-readable
message, <a>reject</a> <var>p</var> with a new
<code>OverconstrainedError</code> created by calling
<code>OverconstrainedError(<var>failedConstraint</var>,
<var>message</var>)</code>, and abort these steps. The
existing constraints remain in effect in this case.</p>
</li>
<li>In a single operation, remove the existing constraints
from <var>object</var>, apply <var>newConstraints</var>,
and apply <var>successfulSettings</var> as the current
settings.</li>
<li>Finally, <a>resolve</a> <var>p</var>.
</li>
</ol>
<li>In a single operation, remove the existing constraints
from <var>object</var>, apply <var>newConstraints</var>,
and apply <var>successfulSettings</var> as the current
settings.
</li>
<li>
<p>Return <var>p</var>.</p>
<li>Return <code>undefined</code>.
</li>
</ol>
<p>The User Agent MAY choose new settings for the constrainable
Expand Down

0 comments on commit ea35f26

Please sign in to comment.