mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Remove tasks for destroyed documents instead of running them
Previously, destroyed-document tasks were forced to be runnable to prevent them from leaking in the task queue. Instead, discard them during task selection so their callbacks never run with stale state. This used to cause issues with a couple of `spin_until()`s in the past, but since we've removed some of them that had to do with the document lifecycle, let's see if we can stick closer to the spec now.
This commit is contained in:
committed by
Andreas Kling
parent
71ba774083
commit
c8baa6e179
Notes:
github-actions[bot]
2026-03-19 20:25:47 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/c8baa6e179a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8513
@@ -1391,10 +1391,6 @@ void Navigable::populate_session_history_entry_document(
|
||||
|
||||
// 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps:
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(heap(), [this, entry, received_navigation_params = move(received_navigation_params), navigation_id, user_involvement, completion_steps, csp_navigation_type, signal_to_continue_session_history_processing]() mutable {
|
||||
// NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
|
||||
if (has_been_destroyed())
|
||||
return;
|
||||
|
||||
// 1. If navigable's ongoing navigation no longer equals navigationId, then run completionSteps and abort these steps.
|
||||
if (navigation_id.has_value() && ongoing_navigation() != navigation_id) {
|
||||
if (completion_steps) {
|
||||
@@ -1871,7 +1867,6 @@ void Navigable::begin_navigation(NavigateParams params)
|
||||
|
||||
// 3. Queue a global task on the navigation and traversal task source given navigable's active window to abort a document and its descendants given navigable's active document.
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), GC::create_function(heap(), [this] {
|
||||
VERIFY(this->active_document());
|
||||
this->active_document()->abort_a_document_and_its_descendants();
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user