[webkit-changes] [WebKit/WebKit] 78e457: Memory consumption/leak with img out of viewport a...

Przemyslaw Gorszkowski noreply at github.com
Tue Nov 14 19:58:24 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 78e4577732ca7734bfb275b4841c134331d91827
      https://github.com/WebKit/WebKit/commit/78e4577732ca7734bfb275b4841c134331d91827
  Author: Przemyslaw Gorszkowski <pgorszkowski at igalia.com>
  Date:   2023-11-14 (Tue, 14 Nov 2023)

  Changed paths:
    A LayoutTests/fast/dom/dynamic-image-with-lazy-loading-leak-expected.txt
    A LayoutTests/fast/dom/dynamic-image-with-lazy-loading-leak.html
    M Source/WebCore/loader/ImageLoader.cpp
    M Source/WebCore/loader/ImageLoader.h

  Log Message:
  -----------
  Memory consumption/leak with img out of viewport and lazy loading
https://bugs.webkit.org/show_bug.cgi?id=263521

Reviewed by Chris Dumez.

This change fixes the problem with dangling of dynamically created (in JS)
HTMLImageElement when it is detached from the document before loading the resource
starts. It happened when img element was created (dynamically) with lazy loading
and the element was outside the viewport (the loading of resource is deferred until
the img element becomes visible). If the element was removed from document it
becomes dangling element and will never be deleted by GC.

* Source/WebCore/loader/ImageLoader.cpp:
(WebCore::ImageLoader::hasPendingActivity const):

To avoid leaking of the dynamically created element, the pending activity of
the element should check has the load of the resource actually started.
Similar check is done in case of static HTMLImageElement in
ImageLoader::updatedHasPendingEvent.

* Source/WebCore/loader/ImageLoader.h:
(WebCore::ImageLoader::hasPendingActivity const): Deleted.

Moved implementation to cpp file.

 * LayoutTests/fast/dom/dynamic-image-with-lazy-loading-leak-expected.txt: Added.
 * LayoutTests/fast/dom/dynamic-image-with-lazy-loading-leak.html: Added.

Canonical link: https://commits.webkit.org/270745@main




More information about the webkit-changes mailing list