mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Prevent running permanently unrunnable tasks in EventLoop
In `::spin_processing_tasks_with_source_until()`, we would first take a set of tasks based on a filter, and then run them one by one. If there was more than one task matched and put in that vector, they could interfere with each other's runnability by making later tasks permanently unrunnable. The `::take_tasks_matching()` API is a footgun - remove it in favor of an API that takes tasks one by one, performing the runnability check just in time.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
f5d76ec2d0
commit
a5000d07c0
Notes:
github-actions[bot]
2026-03-26 17:49:49 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/a5000d07c0f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8627 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/tcl3
@@ -617,17 +617,15 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::load_element()
|
||||
// any ongoing fetch operation. Therefore, all resource selection algorithms will be cancelled before a new
|
||||
// one begins.
|
||||
|
||||
// 2. Let pending tasks be a list of all tasks from the media element's media element event task source in one of the task queues.
|
||||
[[maybe_unused]] auto pending_tasks = HTML::main_thread_event_loop().task_queue().take_tasks_matching([&](auto& task) {
|
||||
// 2. Let pending tasks be a list of all tasks from the media element's media element event task source in one of
|
||||
// the task queues.
|
||||
// FIXME: 3. For each task in pending tasks that would resolve pending play promises or reject pending play promises,
|
||||
// immediately resolve or reject those promises in the order the corresponding tasks were queued.
|
||||
// 4. Remove each task in pending tasks from its task queue
|
||||
main_thread_event_loop().task_queue().remove_tasks_matching([&](auto& task) {
|
||||
return task.source() == media_element_event_task_source();
|
||||
});
|
||||
|
||||
// FIXME: 3. For each task in pending tasks that would resolve pending play promises or reject pending play promises, immediately resolve or
|
||||
// reject those promises in the order the corresponding tasks were queued.
|
||||
|
||||
// 4. Remove each task in pending tasks from its task queue
|
||||
// NOTE: We performed this step along with step 2.
|
||||
|
||||
// 5. If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, queue a media element task given the media element to
|
||||
// fire an event named abort at the media element.
|
||||
if (m_network_state == NetworkState::Loading || m_network_state == NetworkState::Idle) {
|
||||
|
||||
Reference in New Issue
Block a user