- From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
- Date: Tue, 22 Sep 2020 14:32:36 +0000
- To: public-webrtc-logs@w3.org
Both _"queue a task"_ statements above queue tasks on the _main_ event loop.
Crucially, the main event loop's _microtask_ queue is [emptied](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model:perform-a-microtask-checkpoint) at the end of **_each_** main task.
Let's say both _"queue a task"_ you mention happen. The main event loop now contains [T1, T2].
1. We execute T1 (SLD success):
1. The _"Resolve p with undefined"_ [queues a microtask](https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-microtask) on the main event loop's microtask: [M1].
2. We run off the end of JS, where we **_empty the microtask queue_**. This executes M1:
1. This runs `foo` in the `then`
2. We execute T2 (surface ICE candidate).
Check out [In the Loop](https://www.youtube.com/watch?v=cCOL7MC4Pl0&feature=youtu.be&t=1594) explaining how microtask queues blocks rendering.
--
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2574#issuecomment-696761286 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 22 September 2020 14:32:38 UTC