LibWeb: Account text and image storage as external memory

Report DOM character data, decoded image frames, ImageBitmap pixel
buffers, and 2D canvas surfaces through the GC external memory hook.
This lets image and text-heavy pages participate in GC threshold
calculations through their retained backing storage.
This commit is contained in:
Andreas Kling
2026-05-06 00:34:52 +02:00
committed by Andreas Kling
parent 68fa684f76
commit a414136d7c
Notes: github-actions[bot] 2026-05-07 08:04:42 +00:00
10 changed files with 67 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
*/
#include <LibGfx/Bitmap.h>
#include <LibJS/Runtime/ExternalMemory.h>
#include <LibWeb/Bindings/ImageBitmap.h>
#include <LibWeb/HTML/ImageBitmap.h>
#include <LibWeb/HTML/StructuredSerialize.h>
@@ -72,6 +73,14 @@ void ImageBitmap::visit_edges(Cell::Visitor& visitor)
Base::visit_edges(visitor);
}
size_t ImageBitmap::external_memory_size() const
{
auto size = Base::external_memory_size();
if (m_bitmap)
size = JS::saturating_add_external_memory_size(size, m_bitmap->data_size());
return size;
}
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#the-imagebitmap-interface:serialization-steps
WebIDL::ExceptionOr<void> ImageBitmap::serialization_steps(HTML::TransferDataEncoder& serialized, bool, HTML::SerializationMemory&)
{