Skip to content

Commit a0e2856

Browse files
committed
Use HTML's "run steps after a timeout"
This ensures delayed postTask()-scheduled tasks contribute to idle deadline computation, and are automatically removed from consideration on global destruction.
1 parent 2a4905b commit a0e2856

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

spec/scheduling-tasks.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -246,34 +246,18 @@ Processing Model {#sec-scheduling-tasks-processing-model}
246246
1. Let |queue| be the result of [=selecting the scheduler task queue=] for
247247
|scheduler| given |signal| and |priority|.
248248
1. Let |delay| be |options|["{{SchedulerPostTaskOptions/delay}}"].
249-
1. If |delay| is greater than 0, then run these steps [=in parallel=]:
250-
1. Let |global| be the [=relevant global object=] for |scheduler|.
251-
1. If |global| is a {{Window}} object, wait until |global|'s
252-
<a attribute for="Window">associated <code>Document</code></a>
253-
has been [=Document/fully active=] for a further |delay| milliseconds (not necessarily
254-
consecutively).
255-
256-
Otherwise, |global| is a {{WorkerGlobalScope}} object; wait until |delay|
257-
milliseconds have passed with the worker not suspended (not necessarily
258-
consecutively).
259-
260-
1. Wait until any invocations of this algorithm that had the same |scheduler|,
261-
that started before this one, and whose |delay| is equal to or less
262-
than this one's, have completed.
263-
1. Optionally, wait a further [=implementation-defined=] length of time.
249+
1. If |delay| is greater than 0, then [=run steps after a timeout=] given
250+
|scheduler|'s [=relevant global object=], "`scheduler-postTask`",
251+
|delay|, and the following steps:
264252
1. [=Schedule a task to invoke a callback=] for |scheduler| given |queue|,
265253
|signal|, |callback|, and |result|.
266254
1. Otherwise, [=schedule a task to invoke a callback=] for |scheduler| given
267255
|queue|, |signal|, |callback|, and |result|.
268256
1. Return |result|.
269257
</div>
270258

271-
Issue: We need to figure out exactly how we want to spec delayed tasks, and if
272-
we can refactor the timer spec to use a common method. As written, this uses
273-
steps 15&ndash;17 of the timer initialization steps algorithm, but there are a
274-
couple things we might want to change: (1) how to account for suspend? (2) how
275-
to account for current throttling techniques (see also
276-
[this issue](https://github.com/whatwg/html/issues/5925))?
259+
Issue: [=Run steps after a timeout=] doesn't necessarily account for suspension;
260+
see [whatwg/html#5925](https://github.com/whatwg/html/issues/5925).
277261

278262
<div algorithm="select the scheduler task queue">
279263
To <dfn lt="select the scheduler task queue|selecting the scheduler task queue">select the scheduler task queue</dfn>

0 commit comments

Comments
 (0)