Skip to content

Commit 0c800c5

Browse files
tidoustmarkafoltz
authored andcommitted
Issue #387: Monitoring algo takes pending request to start into account (#392)
* Issue #387: Monitoring algo now takes pending request to start into account Main changes: - Prose similar to that used in the Web Bluetooth spec used for the garbage collection note for the "presentation display availability" to clarify the intent. We may want to adjust this text in #391. - Notion of "presentation availability promise" dropped. That promise is now referenced in `getAvailability` as "an unsettled Promise from a previous call to `getAvailability` on `presentationRequest`". This avoids having to be explicit about garbage collection rules. - Step that instructs the UA to run the monitoring algorithm no longer runs "in parallel" (see #381) - Note added next to that step to clarify that the monitoring algorithm needs to run again even if it is still running - The monitoring algorithm now starts by making a shallow copy of the "set of presentation availability objects" which gets completed with the right tuple if there is a pending call to `start` (note there can be at most one such pending call per controlling browsing context) - Steps that update the `value` property adjusted to set the value directly for `PresentationAvailability` objects that have not yet been exposed to ECMAScript object. This is triggered by the following (new) problem: the `getAvailibility` promise gets resolved with a `PresentationAvailability` object as soon as the monitoring algorithm is done running, but the monitoring algorithm "queued a task" to update the `value` property of `PresentationAvailability` objects. The `value` property of the returned `PresentationAvailability` object would always have been the initial value (`false` in most cases), even if the monitoring algorithm had found an available display. Also, we probably do not want to fire `change` events for properties that JS code has not yet been given any chance to read. Here as well, we may want to adjust this text in #391. - The initial `value` of newly created `PresentationAvailability` objects is now always `false`. There should be no need to set it to `true` given that the monitoring algorithm refreshes that value right after that (and given the previous fix). - I added a note next to the monitoring algorithm to clarify that a user agent may interrupt and re-run the algorithm to group requests, which seems like a possible optimization. * Issue #387: Use availabilitySet in the monitoring algorithm The variable is obviously useless if it is not referenced. This should have been part of previous commit. * Issue #387: drop "exposed to JS" and allow monitoring aggregation This commit drops the fuzzy "exposed to ECMAScript" wording in the monitoring algorithm, and replaces it with a more common "initialized" concept. The notion is clarified in an editorial note next to the step that uses it. The editorial note that follows the monitoring algorithm was also complete to mention that user agents may aggregate monitoring activities across browsing contexts. * Issue #387: Update notes with @mfoltzgoogle suggestions
1 parent f2f4fee commit 0c800c5

File tree

1 file changed

+71
-57
lines changed

1 file changed

+71
-57
lines changed

index.html

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,10 +1126,10 @@

11261126
abort these steps.
11271127
li>
11281128
<li>If there is already an unsettled <a>Promisea> from a previous
1129-
call to <code>startcode> on any <code>PresentationRequestcode>
1130-
in the same <a>controlling browsing contexta>, return a new
1131-
<a>Promise</a> rejected with an <a>OperationErrora> exception and
1132-
abort all remaining steps.
1129+
call to <a for="PresentationRequest">starta> on any
1130+
<a>PresentationRequesta> in the same <a>controlling browsing
1131+
context</a>, return a new <a>Promisea> rejected with an
1132+
<a>OperationErrora> exception and abort all remaining steps.
11331133
li>
11341134
<li>Let <var>Pvar> be a new <a>Promisea>.
11351135
li>
@@ -1551,6 +1551,11 @@

15511551
any <a>available presentation displaya> for at least one of the
15521552
<a>presentation request URLsa> of the request.
15531553
p>
1554+
<p>
1555+
The <a>presentation display availabilitya> for a presentation
1556+
request is eligible for garbage collection when no ECMASCript code
1557+
can observe the <code>PresentationAvailabilitycode> object.
1558+
p>
15541559
<p>
15551560
If the <a>controlling user agenta> can <a>monitor the list of
15561561
available presentation displaysa> in the background (without a
@@ -1561,8 +1566,9 @@

15611566
p>
15621567
<p>
15631568
The <dfn for="PresentationAvailability">valuedfn> attribute MUST
1564-
return the last value it was set to. The value is updated by the
1565-
<a>monitor the list of available presentation displaysa> algorithm.
1569+
return the last value it was set to. The value is initialized and
1570+
updated by the <a>monitor the list of available presentation
1571+
displaysa> algorithm.
15661572
p>
15671573
<p>
15681574
The <dfn for="PresentationAvailability">onchangedfn> attribute is
@@ -1573,15 +1579,6 @@

15731579
<h4>
15741580
The set of presentation availability objects
15751581
h4>
1576-
<p>
1577-
Each <code>PresentationRequestcode> has a <a>presentation
1578-
availability promisea> and a <a>presentation display
1579-
availabilitya>, which are initially set to <code>nullcode>. The
1580-
<dfn>presentation availability promisedfn> for a
1581-
<code>PresentationRequestcode> is a <code>Promisecode> object
1582-
that <a data-lt="resolve">resolvesa> to the <a>presentation
1583-
display availabilitya> for the request.
1584-
p>
15851582
<p>
15861583
The <a>user agenta> MUST keep track of the <dfn>set of
15871584
presentation availability objectsdfn> created by the
@@ -1686,19 +1683,15 @@

16861683
li>
16871684
ol>
16881685
li>
1689-
<li>If the <a>presentation availability promisea> for
1690-
<code>presentationRequestcode> is not <code>nullcode>, return
1691-
the <code>presentationRequestcode> object's <a>presentation
1692-
availability promisea> and abort these steps.
1686+
<li>If there is an unsettled <a>Promisea> from a previous call to
1687+
<a for="PresentationRequest">getAvailabilitya> on
1688+
<code>presentationRequestcode>, return that <a>Promisea> and
1689+
abort these steps.
16931690
li>
1694-
<li>Otherwise, set the <code>presentationRequestcode> object's
1695-
<a>presentation availability promisea> to a newly created <code>
1696-
Promisecode> object and set <var>Pvar> to this
1697-
<code>Promisecode>.
1691+
<li>Otherwise, let <var>Pvar> be a new <a>Promisea>.
16981692
li>
1699-
<li>Return the <code>presentationRequestcode> object's
1700-
<a>presentation availability promisea>, but continue running
1701-
these steps <a>in parallela>.
1693+
<li>Return <var>Pvar>, but continue running these steps <a>in
1694+
parallela>.
17021695
li>
17031696
<li>If the user agent is unable to continuously <a>monitor the list
17041697
of available presentation displaysa> in the background, but can
@@ -1726,34 +1719,20 @@

17261719
li>
17271720
<li>Set the <a>presentation display availabilitya> for
17281721
<var>presentationRequestvar> to a newly created
1729-
<code>PresentationAvailabilitycode> object, and let <var>Avar>
1730-
be that object.
1731-
li>
1732-
<li>Set the <code>valuecode> property of <var>Avar> as follows:
1733-
<ol>
1734-
<li>
1735-
<code>falsecode> if the <a>list of available presentation
1736-
displaysa> is empty.
1737-
li>
1738-
<li>
1739-
<code>truecode> if there is at least one <a>available
1740-
presentation displaya> for some member of
1741-
<var>presentationUrlsvar>. That is, there is an entry
1742-
<var>(presentationUrl, display)var> in the <a>list of
1743-
available presentation displaysa> for some
1744-
<var>presentationUrlvar> in <var>presentationUrlsvar>.
1745-
li>
1746-
<li>
1747-
<code>falsecode> otherwise.
1748-
li>
1749-
ol>
1722+
<a>PresentationAvailabilitya> object, and let <var>Avar> be
1723+
that object.
17501724
li>
17511725
<li>Create a tuple <em>(<var>Avar>,
17521726
<var>presentationUrlsvar>)em> and add it to the <a>set of
17531727
presentation availability objectsa>.
17541728
li>
17551729
<li>Run the algorithm to <a>monitor the list of available
1756-
presentation displaysa> <a>in parallela>.
1730+
presentation displaysa>.
1731+
<div class="note">
1732+
The monitoring algorithm must be run at least one more time
1733+
after the previous step to pick up the tuple that was added to
1734+
the <a>set of presentation availability objectsa>.
1735+
div>
17571736
li>
17581737
<li>
17591738
<a>Resolvea> <var>Pvar> with <var>Avar>.
@@ -1770,11 +1749,28 @@

17701749
"PresentationRequest" data-lt="start">select a presentation
17711750
displaya>, the <a>user agenta> MUST <dfn>monitor the list of
17721751
available presentation displaysdfn> by running the following
1773-
steps.
1752+
steps:
17741753
p>
17751754
<ol link-for="PresentationAvailability">
1776-
<li>Set the <a>list of available presentation displaysa> to the
1777-
empty list.
1755+
<li>Let <var>availabilitySetvar> be a shallow copy of the <a>set
1756+
of presentation availability objectsa>.
1757+
li>
1758+
<li>If there is a pending request to <a for="PresentationRequest"
1759+
data-lt="start">select a presentation displaya> for a
1760+
<a>PresentationRequesta> and if the <a>PresentationRequesta>'s
1761+
<a>presentation display availabilitya> is <code>nullcode>, then
1762+
run the following substeps:
1763+
<ol>
1764+
<li>Let <var>Avar> be a newly created
1765+
<a>PresentationAvailabilitya> object.
1766+
li>
1767+
<li>Create a tuple <em>(<var>Avar>,
1768+
<var>presentationUrlsvar>)em> where
1769+
<var>presentationUrlsvar> is the <a>PresentationRequesta>'s
1770+
<a>presentation request URLsa> and add it to
1771+
<var>availabilitySetvar>.
1772+
li>
1773+
ol>
17781774
li>
17791775
<li>Let <var>newDisplaysvar> be an empty list.
17801776
li>
@@ -1785,9 +1781,12 @@

17851781
<li>Retrieve <a>presentation displaysa> (using an implementation
17861782
specific mechanism) and set <var>newDisplaysvar> to this list.
17871783
li>
1784+
<li>Set the <a>list of available presentation displaysa> to the
1785+
empty list.
1786+
li>
17881787
<li>For each member <em>(<var>Avar>,
1789-
<var>availabilityUrlsvar>)em> of the <a>set of presentation
1790-
availability objectsa>, run the following steps:
1788+
<var>availabilityUrlsvar>)em> of <var>availabilitySetvar>,
1789+
run the following steps:
17911790
<ol>
17921791
<li>Set <var>previousAvailabilityvar> to the value of
17931792
<var>Avar>'s <a>valuea> property.
@@ -1814,6 +1813,10 @@

18141813
li>
18151814
ol>
18161815
li>
1816+
<li>If <var>Avar>'s <a>valuea> property has not yet been
1817+
initialized, then set <var>Avar>'s <a>valuea> property to
1818+
<var>newAvailabilityvar> and skip the following step.
1819+
li>
18171820
<li>If <var>previousAvailabilityvar> is not equal to
18181821
<var>newAvailabilityvar>, then <a>queue a taska> to run the
18191822
following steps:
@@ -1830,15 +1833,26 @@

18301833
ol>
18311834
li>
18321835
ol>
1836+
<div class="note">
1837+
The <a>controlling user agenta> may choose how often to
1838+
<a>monitor the list of available presentation displaysa>,
1839+
including grouping requests from <a for=
1840+
"PresentationRequest">starta> and <a for=
1841+
"PresentationRequest">getAvailabilitya>, and aggregating them
1842+
across <a data-lt="browsing context">browsing contextsa>.
1843+
div>
18331844
<p>
1834-
When a <a>PresentationAvailabilitya> object is no longer alive
1835-
(i.e., is eligible for garbage collection), the <a>user agenta>
1836-
SHOULD run the following steps:
1845+
When a <a>presentation display availabilitya> object is eligible
1846+
for garbage collection, the <a>user agenta> SHOULD run the
1847+
following steps:
18371848
p>
18381849
<ol>
1850+
<li>Let <var>Avar> be the newly deceased
1851+
<a>PresentationAvailabilitya> object
1852+
li>
18391853
<li>Find and remove any entry <em>(<var>Avar>,
18401854
<var>availabilityUrlvar>)em> in the <a>set of presentation
1841-
availability objectsa> for the newly deceased <var>Avar>.
1855+
availability objectsa>.
18421856
li>
18431857
<li>If the <a>set of presentation availability objectsa> is now
18441858
empty and there is no pending request to <a for=

0 commit comments

Comments
 (0)