@@ -122199,8 +122199,8 @@ interface <dfn interface>BroadcastChannel</dfn> : <span>EventTarget</span> {
122199
122199
<code>Document</code></span> is <span>fully active</span>, or</p></li>
122200
122200
122201
122201
<li><p>a <code>WorkerGlobalScope</code> object whose <span
122202
- data-x="dom-WorkerGlobalScope-closing">closing</span> flag is false and whose
122203
- <span>worker</span> is not a <span> suspendable worker</span>.</p></li>
122202
+ data-x="dom-WorkerGlobalScope-closing">closing</span> flag is false and is not <span
122203
+ data-x=" suspendable worker">suspendable </span>.</p></li>
122204
122204
</ul>
122205
122205
122206
122206
<p>The <dfn method for="BroadcastChannel"><code
@@ -123081,35 +123081,132 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope
123081
123081
123082
123082
<hr>
123083
123083
123084
- <p>A worker is said to be a <dfn>permissible worker</dfn> if its <code>WorkerGlobalScope</code>'s
123085
- <span>owner set</span> is not <span data-x="list is empty">empty</span> or:</p>
123084
+ <p>A user agent has an <span>implementation-defined</span> value, the <dfn>between-loads shared
123085
+ worker timeout</dfn>, which is some small amount of time. This represents how long the user agent
123086
+ allows shared workers to survive while a page is loading, in case that page is going to contact
123087
+ the shared worker again. Setting this value to greater than zero lets user agents avoid the cost
123088
+ of restarting a shared worker used by a site when the user is navigating from page to page within
123089
+ that site.</p>
123086
123090
123087
- <ul class=brief>
123088
- <li>its <span>owner set</span> has been <span data-x="list is empty">empty</span> for no more
123089
- than a short <span>implementation-defined</span> timeout value,</li>
123090
- <li>its <code>WorkerGlobalScope</code> object is a <code>SharedWorkerGlobalScope</code> object
123091
- (i.e., the worker is a shared worker), and</li>
123092
- <li>the user agent has a <span>navigable</span> whose <span data-x="nav-document">active
123093
- document</span> is not <span>completely loaded</span>.</li>
123094
- </ul>
123091
+ <p class="note">A typical value for the <span>between-loads shared worker timeout</span> might be
123092
+ 5 seconds.</p>
123093
+
123094
+ <hr>
123095
+
123096
+ <p>A <code>WorkerGlobalScope</code> <var>global</var> is <dfn data-x="active needed
123097
+ worker">actively needed</dfn> if the following algorithm returns true:</p>
123098
+
123099
+ <ol>
123100
+ <li>
123101
+ <p><span data-x="list iterate">For each</span> <var>owner</var> of <var>global</var>'s
123102
+ <span>owner set</span>:</p>
123103
+
123104
+ <ol>
123105
+ <li><p>If <var>owner</var> is a <code>Document</code>, and <var>owner</var> is <span>fully
123106
+ active</span>, then return true.</p></li>
123107
+
123108
+ <li><p>If <var>owner</var> is a <code>WorkerGlobalScope</code> that is <span data-x="active
123109
+ needed worker">actively needed</span>, then return true.</p></li>
123110
+ </ol>
123111
+ </li>
123112
+
123113
+ <li><p>Return false.</p></li>
123114
+ </ol>
123115
+
123116
+ <p>A <code>WorkerGlobalScope</code> <var>global</var> is <dfn data-x="protected
123117
+ worker">protected</dfn> if the following algorithm returns true:</p>
123118
+
123119
+ <ol>
123120
+ <li><p>If <var>global</var> is not <span data-x="active needed worker">actively needed</span>,
123121
+ then return false.</p></li>
123122
+
123123
+ <li><p>If <var>global</var> is a <code>SharedWorkerGlobalScope</code>, then return true.</p></li>
123124
+
123125
+ <li><p>If <var>global</var>'s <span>the worker's ports</span> is not <span data-x="list is
123126
+ empty">empty</span>, then return true.</p></li>
123127
+
123128
+ <li><p>If <var>global</var> has outstanding timers, database transactions, or network
123129
+ connections, then return true.</p></li>
123130
+ <!-- TODO: would be nice to make the above rigorous. -->
123131
+
123132
+ <li><p>Return false.</p></li>
123133
+ </ol>
123134
+
123135
+ <p>A <code>WorkerGlobalScope</code> <var>global</var> is <dfn data-x="permissible
123136
+ worker">permissible</dfn> if the following algorithm returns true:</p>
123137
+
123138
+ <ol>
123139
+ <li><p>If <var>global</var>'s <span>owner set</span> is not <span data-x="list is
123140
+ empty">empty</span>, then return true.</p></li>
123141
+
123142
+ <li>
123143
+ <p>If all of the following are true:</p>
123095
123144
123096
- <p class="note">The second part of this definition allows a shared worker to survive for a short
123097
- time while a page is loading, in case that page is going to contact the shared worker again. This
123098
- can be used by user agents as a way to avoid the cost of restarting a shared worker used by a site
123099
- when the user is navigating from page to page within that site.</p>
123145
+ <ul>
123146
+ <li><p><var>global</var> is a <code>SharedWorkerGlobalScope</code>;</p></li>
123147
+
123148
+ <li><p><var>global</var>'s <span>owner set</span> has been <span data-x="list is
123149
+ empty">empty</span> for no more than the user agent's <span>between-loads shared worker
123150
+ timeout</span>; and</p>
123151
+
123152
+ <li><p>the user agent has a <span>navigable</span> whose <span data-x="nav-document">active
123153
+ document</span> is not <span>completely loaded</span>,</p></li>
123154
+ </ul>
123155
+
123156
+ <p>then return true.</p>
123157
+ </li>
123158
+
123159
+ <li><p>Return false.</p></li>
123160
+ </ol>
123100
123161
123101
- <p>A worker is said to be an <dfn>active needed worker</dfn> if any of its <span data-x="owner
123102
- set">owners</span> are either <code>Document</code> objects that are <span>fully active</span> or
123103
- <span data-x="active needed worker">active needed workers</span>.</p>
123162
+ <p>A <code>WorkerGlobalScope</code> <var>global</var> is <dfn data-x="suspendable
123163
+ worker">suspendable</dfn> if the following algorithm returns true:</p>
123104
123164
123105
- <p>A worker is said to be a <dfn>protected worker</dfn> if it is an <span>active needed
123106
- worker</span> and either it has outstanding timers, database transactions, or network connections,
123107
- or its list of <span>the worker's ports</span> is not empty, or its <code>WorkerGlobalScope</code>
123108
- is actually a <code>SharedWorkerGlobalScope</code> object (i.e., the worker is a shared
123109
- worker).</p>
123165
+ <ol>
123166
+ <li><p>If <var>global</var> is <span data-x="active needed worker">actively needed</span>, then
123167
+ return false.</p></li>
123110
123168
123111
- <p>A worker is said to be a <dfn>suspendable worker</dfn> if it is not an <span>active needed
123112
- worker</span> but it is a <span>permissible worker</span>.</p>
123169
+ <li><p>If <var>global</var> is <span data-x="permissible worker">permissible</span>, then return
123170
+ true.</p></li>
123171
+
123172
+ <li><p>Return false.</p></li>
123173
+ </ol>
123174
+
123175
+ <div class="note" id="note-worker-lifetime-terminology">
123176
+ <p>These concepts are used elsewhere in the specification's normative requirements as
123177
+ follows:</p>
123178
+
123179
+ <ul>
123180
+ <li><p>Workers get <a href="#step-closing-orphan-workers">closed as orphans</a> between when
123181
+ they stop being <span data-x="protected worker">protected</span> and when they stop being <span
123182
+ data-x="permissible worker">permissible</span>.</p></li>
123183
+
123184
+ <li><p>Workers get <a href="#step-suspending-workers">suspended or un-suspended</a> based on
123185
+ whether they are <span data-x="suspendable worker">suspendable</span>.</p></li>
123186
+
123187
+ <li><p>Workers that have been closed, but keep executing, <a
123188
+ href="#terminate-rampant-workers">can be terminated</a> at the user agent's discretion, once
123189
+ they stop being <span data-x="active needed worker">actively needed</span>.</p></li>
123190
+ </ul>
123191
+
123192
+ <p>Note that every <code>WorkerGlobalScope</code> that is <span data-x="active needed
123193
+ worker">actively needed</span> is <span data-x="protected worker">protected</span>, and every
123194
+ <code>WorkerGlobalScope</code> that is <span data-x="protected worker">protected</span> is <span
123195
+ data-x="permissible worker">permissible</span>. (But the converses do not hold.)</p>
123196
+
123197
+ <p>An important difference between <span data-x="protected worker">protected</span> and <span
123198
+ data-x="permissible worker">permissible</span> is that a <code>WorkerGlobalScope</code> is <span
123199
+ data-x="protected worker">protected</span> only if its transitive set of owners contains at least
123200
+ one <span>fully active</span> <code>Document</code>, whereas a <code>WorkerGlobalScope</code> can
123201
+ be <span data-x="permissible worker">permissible</span> even if all the <code>Document</code>s in
123202
+ its transitive set of owners are in <a href="#note-bfcache">bfcache</a>.</p>
123203
+ </div>
123204
+
123205
+ <p class="note" id="note-between-loads-shared-worker-timeout-lifetime">The <span>between-loads
123206
+ shared worker timeout</span> only influences the definition of <span data-x="permissible
123207
+ worker">permissible</span>, not <span data-x="protected worker">protected</span>, and so
123208
+ implementations are not required to keep shared workers alive for that duration. Rather, they are
123209
+ required to close shared workers after the timeout is reached.</p>
123113
123210
123114
123211
123115
123212
<h4 id="worker-processing-model"><span id="processing-model-10"></span>Processing model</h4>
@@ -123333,21 +123430,19 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope
123333
123430
<li><p>Create a new <code>WorkerLocation</code> object and associate it with <var>worker global
123334
123431
scope</var>.</p>
123335
123432
123336
- <li>
123337
- <p><i>Closing orphan workers</i>: Start monitoring the worker such that no sooner than
123338
- it stops being a <span>protected worker</span>, and no later than it stops being a
123339
- <span>permissible worker</span>, <var>worker global scope</var>'s <span
123340
- data-x="dom-WorkerGlobalScope-closing">closing</span> flag is set to true.</p>
123341
- </li>
123433
+ <li id="step-closing-orphan-workers"><p><i>Closing orphan workers</i>: Start monitoring
123434
+ <var>worker global scope</var> such that no sooner than it stops being <span data-x="protected
123435
+ worker">protected</span>, and no later than it stops being <span data-x="permissible
123436
+ worker">permissible</span>, <var>worker global scope</var>'s <span
123437
+ data-x="dom-WorkerGlobalScope-closing">closing</span> flag is set to true.</p></li>
123342
123438
123343
- <li>
123344
- <p><i>Suspending workers</i>: Start monitoring the worker, such that whenever
123345
- <var>worker global scope</var>'s <span data-x="dom-WorkerGlobalScope-closing">closing</span>
123346
- flag is false and the worker is a <span>suspendable worker</span>, the user agent suspends
123347
- execution of script in that worker until such time as either the <span
123348
- data-x="dom-WorkerGlobalScope-closing">closing</span> flag switches to true or the worker stops
123349
- being a <span>suspendable worker</span>.</p>
123350
- </li>
123439
+ <li id="step-suspending-workers"><p><i>Suspending workers</i>: Start monitoring <var>worker
123440
+ global scope</var>, such that whenever <var>worker global scope</var>'s <span
123441
+ data-x="dom-WorkerGlobalScope-closing">closing</span> flag is false and it is <span
123442
+ data-x="suspendable worker">suspendable</span>, the user agent suspends execution of script in
123443
+ <var>worker global scope</var> until such time as either the <span
123444
+ data-x="dom-WorkerGlobalScope-closing">closing</span> flag switches to true or <var>worker
123445
+ global scope</var> stops being <span data-x="suspendable worker">suspendable</span>.</p></li>
123351
123446
123352
123447
<li><p>Set <var>inside settings</var>'s <span
123353
123448
data-x="concept-environment-execution-ready-flag">execution ready flag</span>.</p></li>
@@ -123439,8 +123534,9 @@ interface <dfn interface>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope
123439
123534
entangled with.</p></li>
123440
123535
</ol>
123441
123536
123442
- <p>User agents may invoke the <span>terminate a worker</span> algorithm when a worker stops being
123443
- an <span>active needed worker</span> and the worker continues executing even after its <span
123537
+ <p id="terminate-rampant-workers">User agents may invoke the <span>terminate a worker</span>
123538
+ algorithm when a worker stops being <span data-x="active needed worker">actively needed</span> and
123539
+ the worker continues executing even after its <span
123444
123540
data-x="dom-WorkerGlobalScope-closing">closing</span> flag was set to true.</p>
123445
123541
123446
123542
</div>
0 commit comments