mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Don't churn HTML::EventLoop while in microtask checkpoint
At the end of HTML::EventLoop::process(), the loop reschedules itself if there are more runnable tasks available. However, the condition was flawed: we would reschedule if there were any microtasks queued, but those tasks will not be processed if we're currently within the scope of a microtask checkpoint. To fix this, we now only reschedule the HTML event loop for microtask processing *if* we're not already in a microtask checkpoint. This fixes the 100% CPU churn seen when looking at PRs on GitHub. :^)
This commit is contained in:
parent
a5b9fb28c2
commit
bc6e61adec
Notes:
sideshowbarker
2024-07-17 01:06:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bc6e61adec Pull-request: https://github.com/SerenityOS/serenity/pull/18125
1 changed files with 2 additions and 2 deletions
|
@ -226,8 +226,8 @@ void EventLoop::process()
|
||||||
|
|
||||||
// FIXME: 2. If there are no tasks in the event loop's task queues and the WorkerGlobalScope object's closing flag is true, then destroy the event loop, aborting these steps, resuming the run a worker steps described in the Web workers section below.
|
// FIXME: 2. If there are no tasks in the event loop's task queues and the WorkerGlobalScope object's closing flag is true, then destroy the event loop, aborting these steps, resuming the run a worker steps described in the Web workers section below.
|
||||||
|
|
||||||
// If there are tasks in the queue, schedule a new round of processing. :^)
|
// If there are eligible tasks in the queue, schedule a new round of processing. :^)
|
||||||
if (m_task_queue.has_runnable_tasks() || !m_microtask_queue.is_empty())
|
if (m_task_queue.has_runnable_tasks() || (!m_microtask_queue.is_empty() && !m_performing_a_microtask_checkpoint))
|
||||||
schedule();
|
schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue