-
Notifications
You must be signed in to change notification settings - Fork 3k
Further clarify worker lifetime relationships #11599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123489,6 +123489,46 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope | |
<li><p>Return false.</p></li> | ||
</ol> | ||
|
||
<div class="note" id="note-worker-lifetime-terminology-relationships"> | ||
<p>The following relationships hold between these terms:</p> | ||
|
||
<ul> | ||
<li><p>Every <code>WorkerGlobalScope</code> that is <span data-x="active needed worker">actively | ||
needed</span> or <span data-x="protected worker">protected</span> is <span data-x="permissible | ||
worker">permissible</span>.</p></li> | ||
|
||
<li><p>Every <code>WorkerGlobalScope</code> that is <span data-x="protected | ||
worker">protected</span> is <span data-x="active needed worker">actively needed</span>.</p></li> | ||
</ul> | ||
|
||
<p>However, the converses do not always hold:</p> | ||
|
||
<ul> | ||
<li><p>A <code>WorkerGlobalScope</code> can be <span data-x="active needed worker">actively | ||
needed</span> but not <span data-x="protected worker">protected</span>, if it's a dedicated | ||
worker with no outstanding async work that is still performing computation on behalf of a fully | ||
active owner, but whose corresponding <code>Worker</code> object has been garbage collected. <a | ||
|
||
href="#ports-and-garbage-collection">Because of the garbage collection</a>, the <span | ||
data-x="the worker's ports">ports</span> collection is empty, so it is no longer protected. | ||
However, its event loop has not yet yielded to <a | ||
href="#step-empty-worker-global-scope-owner-set">empty its owner set</a>, so it is still | ||
actively needed.</p></li> | ||
|
||
<li><p>A <code>WorkerGlobalScope</code> can be <span data-x="permissible | ||
worker">permissible</span> but not <span data-x="protected worker">protected</span> or <span | ||
data-x="active needed worker">actively needed</span>, if all the <code>Document</code>s in its | ||
transitive set of owners are in <a href="#note-bfcache">bfcache</a>, or if it's a | ||
<code>SharedWorkerGlobalScope</code> with no current owners being kept alive for the duration of | ||
the <span>between-loads shared worker timeout</span>.</p></li> | ||
</ul> | ||
</div> | ||
|
||
<p class="note" id="note-between-loads-shared-worker-timeout-lifetime">The <span>between-loads | ||
shared worker timeout</span> only influences the definition of <span data-x="permissible | ||
worker">permissible</span>, not <span data-x="protected worker">protected</span>, and so | ||
implementations are not required to keep shared workers alive for that duration. Rather, they are | ||
required to close shared workers after the timeout is reached.</p> | ||
|
||
<p>A <code>WorkerGlobalScope</code> <var>global</var> is <dfn data-x="suspendable | ||
worker">suspendable</dfn> if the following algorithm returns true:</p> | ||
|
||
|
@@ -123511,33 +123551,15 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope | |
they stop being <span data-x="protected worker">protected</span> and when they stop being <span | ||
data-x="permissible worker">permissible</span>.</p></li> | ||
|
||
<li><p>Workers get <a href="#step-suspending-workers">suspended or un-suspended</a> based on | ||
whether they are <span data-x="suspendable worker">suspendable</span>.</p></li> | ||
|
||
<li><p>Workers that have been closed, but keep executing, <a | ||
href="#terminate-rampant-workers">can be terminated</a> at the user agent's discretion, once | ||
they stop being <span data-x="active needed worker">actively needed</span>.</p></li> | ||
</ul> | ||
|
||
<p>Note that every <code>WorkerGlobalScope</code> that is <span data-x="active needed | ||
worker">actively needed</span> is <span data-x="protected worker">protected</span>, and every | ||
<code>WorkerGlobalScope</code> that is <span data-x="protected worker">protected</span> is <span | ||
data-x="permissible worker">permissible</span>. (But the converses do not hold.)</p> | ||
|
||
<p>An important difference between <span data-x="protected worker">protected</span> and <span | ||
data-x="permissible worker">permissible</span> is that a <code>WorkerGlobalScope</code> is <span | ||
data-x="protected worker">protected</span> only if its transitive set of owners contains at least | ||
one <span>fully active</span> <code>Document</code>, whereas a <code>WorkerGlobalScope</code> can | ||
be <span data-x="permissible worker">permissible</span> even if all the <code>Document</code>s in | ||
its transitive set of owners are in <a href="#note-bfcache">bfcache</a>.</p> | ||
<li><p>Workers get <a href="#step-suspending-workers">suspended or un-suspended</a> based on | ||
whether they are <span data-x="suspendable worker">suspendable</span>.</p></li> | ||
</ul> | ||
</div> | ||
|
||
<p class="note" id="note-between-loads-shared-worker-timeout-lifetime">The <span>between-loads | ||
shared worker timeout</span> only influences the definition of <span data-x="permissible | ||
worker">permissible</span>, not <span data-x="protected worker">protected</span>, and so | ||
implementations are not required to keep shared workers alive for that duration. Rather, they are | ||
required to close shared workers after the timeout is reached.</p> | ||
|
||
|
||
<h4 id="worker-processing-model"><span id="processing-model-10"></span>Processing model</h4> | ||
|
||
|
@@ -123831,11 +123853,8 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope | |
<p>Disentangle all the ports in the list of <span>the worker's ports</span>.</p> | ||
</li> | ||
|
||
<li> | ||
<!-- this has no normative impact but makes it clearer that the worker is irrelevant now, and | ||
doesn't have to survive until its Documents all die off too --> <p><span data-x="list | ||
empty">Empty</span> <var>worker global scope</var>'s <span>owner set</span>.</p> | ||
</li> | ||
<li id="step-empty-worker-global-scope-owner-set"><p><span data-x="list empty">Empty</span> | ||
<var>worker global scope</var>'s <span>owner set</span>.</p></li> | ||
</ol> | ||
</li> | ||
</ol> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this wording. Below you're saying workers can be actively needed but not protected, you supply a specific example that proves this is true, and then right here on this line, you say "this relationship does not hold". Should we just change this paragraph to say something like "The following are also true:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I changed to "However, the converses do not always hold." If that's still confusing we can retreat to something like "However, note the following:".