Skip to content

Commit

Permalink
Rework handling of fully active status
Browse files Browse the repository at this point in the history
Related to #275, where it is explained that the current model of activating
data delivery again when a document becomes fully active is unclear.

Furthermore, doing the same thing to workers based on whether they are
active needed workers or not does not have precedent in other specs and it
is not clear if the current steps even work or not.

Instead, do the following:
- Remove the steps that handle a document becoming fully active again and
  point to #275.
- Remove the steps that handle a worker becoming an active needed worker
  again for symmetry (and also because it is not clear if it _can_ become an
  active worker again once it it stops being so).
- Merge the "Handle unloading document and closing of workers" section into
  the "Handling change of fully active" one.
  - For documents, the former was basically duplicating the latter. In fact,
    the "unloading document cleanup steps" are how specs are supposed to
    react to a document no longer being fully active.
  - For workers, the "active needed worker" references have been replaced by
    a check for the value of the `closing` flag in WorkerGlobalScope.
- Use proper algorithm steps instead of prose to outline the steps that must
  be performed in both cases.
  • Loading branch information
rakuco committed Jun 4, 2024
1 parent e6022a2 commit 33d8962
Showing 1 changed file with 57 additions and 39 deletions.
96 changes: 57 additions & 39 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1268,53 +1268,71 @@ <h3>Notify Pressure Observers</h3>
</ol>
</section>
<section>
<h3>Handling change of fully active</h3>
<h3>Handling change of [=Document/fully active=] status</h3>
<p>
When a {{Document}} |document| is no longer [=Document/fully active=],
deactivate [=data delivery=] of data of all [=supported source types=] to |document|'s [=relevant global object=].
This specification defines the following [=unloading document cleanup
steps=] given a {{Document}} |document|:
</p>
<p>
When a worker with associated {{WorkerGlobalScope}} |relevantGlobal| is no longer
an <a href="https://html.spec.whatwg.org/multipage/workers.html#active-needed-worker">
active needed workers</a>,
deactivate [=data delivery=] of data of all [=supported source types=] to |relevantGlobal|.
</p>
<p>
When a {{Document}} |document| becomes [=Document/fully active=],
for each non-[=list/empty=] [=registered observer list=] associated the [=source type=] |source|,
activate [=data delivery=] of |source| data to |document|'s [=relevant global object=].
</p>
<p>
When a worker with associated {{WorkerGlobalScope}} |relevantGlobal| becomes
an <a href="https://html.spec.whatwg.org/multipage/workers.html#active-needed-worker">
active needed workers</a>,
for each non-[=list/empty=] [=registered observer list=] associated the [=source type=] |source|,
activate [=data delivery=] of |source| data to |document|'s [=relevant global object=].
<ol class="algorithm">
<li>
Let |relevantGlobal| be |document:Document|'s [=relevant global
object=].
</li>
<li>
[=list/For each=] |source| [=map/key=] of the [=registered observer
list=] [=ordered map=]:
<ol>
<li>
Deactivate [=data delivery=] of |source| to |relevantGlobal|.
</li>
</ol>
</li>
</ol>
<p class="issue" data-number="275">
This specification previously included steps covering the case of a
{{Document}} becoming [=Document/fully active=] again (i.e. integration
with {{Document}}'s [=Document/reactivate=] steps). Those steps have been
removed while the intended behavior is discussed.
</p>
</section>

<section>
<h3>Handling changes to worker status</h3>

<aside class="note">
When a document is no longer [=Document/fully active=] (or associated workers no longer
<a href="https://html.spec.whatwg.org/multipage/workers.html#active-needed-worker">
active needed workers</a>), like when
entering the back/forward cache, or "BFCache" for short, then no events are send to the pressure observers
(see [=may receive data=])
in accordance with <a href="https://www.w3.org/TR/design-principles/#listen-fully-active">
Web Platform Design Principles: Listen for changes to fully active status</a>. This means that the
system can safely deactivate [=data delivery=] from the associated [=platform collector=],
but also that it needs to be re-activated when the opposite happens.
<p>
This section is similar to the above, but for workers, which do not
have an equivalent for the [=unloading document cleanup steps=].
</p>
</aside>
</section>

<section id="unload-observers">
<h3>Handle unloading document and closing of workers</h3>
<p>
When a worker with associated {{WorkerGlobalScope}} |relevantGlobal|,
once |relevantGlobal|'s [=WorkerGlobalScope/closing=] flag is set to true,
deactivate [=data delivery=] for all [=supported source types=] to |relevantGlobal|.
</p>
<!--
Note: the steps below do not properly fit into the the process model for
Workers in the HTML spec (i.e. they are not specifically invoked from one
or more locations).
The WebDriver BiDi spec does something similar with different language
that can serve as inspiration:
https://w3c.github.io/webdriver-bidi/#event-script-realmDestroyed
-->

<p>
As one of the [=unloading document cleanup steps=] given {{Document}} |document|,
deactivate [=data delivery=] for all [=supported source types=] to |document|'s [=relevant global object=].
Whenever a {{WorkerGlobalScope}} |relevantGlobal|'s
[=WorkerGlobalScope/closing=] flag is set to true, perform the following
steps:
</p>

<ol class="algorithm">
<li>
[=list/For each=] |source| [=map/key=] of the [=registered observer
list=] [=ordered map=]:
<ol>
<li>
Deactivate [=data delivery=] of |source| to |relevantGlobal|.
</li>
</ol>
</li>
</ol>
</section>
</section>
</section> <!-- Pressure Observer -->
Expand Down

0 comments on commit 33d8962

Please sign in to comment.