mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 02:33:03 +00:00
LibWeb: Run queued HTML tasks after associated document is destroyed
Before this change, tasks associated with a destroyed document would get stuck in the task queue forever, since document-associated tasks are not allowed to run when their document isn't fully active (and destroyed documents never become fully active again). This caused everything captured by task callbacks to leak. We now treat tasks for destroyed documents as runnable immediately, which gets them out of the queue. This fixes another massive GC leak on Speedometer.
This commit is contained in:
parent
53c9c6f3ee
commit
187f8c5460
Notes:
github-actions[bot]
2025-02-07 15:54:13 +00:00
Author: https://github.com/awesomekling
Commit: 187f8c5460
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3488
Reviewed-by: https://github.com/shannonbooth
3 changed files with 18 additions and 1 deletions
|
@ -51,7 +51,15 @@ void Task::execute()
|
|||
bool Task::is_runnable() const
|
||||
{
|
||||
// A task is runnable if its document is either null or fully active.
|
||||
return !m_document.ptr() || m_document->is_fully_active();
|
||||
if (!m_document)
|
||||
return true;
|
||||
|
||||
// AD-HOC: If the document has been destroyed, we'll consider the task runnable.
|
||||
// Otherwise it would get stuck here forever, since a destroyed document never becomes fully active again.
|
||||
if (m_document->has_been_destroyed())
|
||||
return true;
|
||||
|
||||
return m_document->is_fully_active();
|
||||
}
|
||||
|
||||
DOM::Document const* Task::document() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue