mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibWeb+WebContent: Don't let PageClient keep documents alive
We were inadvertently keeping all documents alive by installing a console client for them. This patch fixes the issue by adding a finalizer to Document, and having that be the way we detach console clients. This breaks the cycle. With this change, we can spam set .innerHTML in a loop and memory usage remains stable. Fixes #14612
This commit is contained in:
parent
cd6a458e83
commit
44659f2f2a
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/awesomekling
Commit: 44659f2f2a
Pull-request: https://github.com/SerenityOS/serenity/pull/24035
Issue: https://github.com/SerenityOS/serenity/issues/14612
4 changed files with 9 additions and 4 deletions
|
@ -408,6 +408,12 @@ WebIDL::ExceptionOr<void> Document::populate_with_html_head_and_body()
|
|||
return {};
|
||||
}
|
||||
|
||||
void Document::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
page().client().page_did_destroy_document(*this);
|
||||
}
|
||||
|
||||
void Document::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
@ -3070,8 +3076,6 @@ void Document::run_unloading_cleanup_steps()
|
|||
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#destroy-a-document
|
||||
void Document::destroy()
|
||||
{
|
||||
page().client().page_did_destroy_document(*this);
|
||||
|
||||
// NOTE: Abort needs to happen before destory. There is currently bug in the spec: https://github.com/whatwg/html/issues/9148
|
||||
// 4. Abort document.
|
||||
abort();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue