[Webkit-unassigned] [Bug 227194] New: ResizeObserver / IntersectionObserver memory leak on detached & out of reference elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jun 20 10:39:03 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=227194

            Bug ID: 227194
           Summary: ResizeObserver / IntersectionObserver memory leak on
                    detached & out of reference elements
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Layout and Rendering
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: jaffathecake at gmail.com
                CC: bfulgham at webkit.org, simon.fraser at apple.com,
                    zalan at apple.com

```
const weakMap = new WeakMap();

button.onclick = () => {
  const el = document.createElement('div');

  weakMap.set(el, new Uint8Array(1000 * 1000 * 100));

  new ResizeObserver(
    () => console.log('resize', el.getBoundingClientRect())
  ).observe(el);

  document.body.append(el);
  setTimeout(() => el.remove(), 0);
}
```

Each click leaks an element. In this case that's 100mb.

Demo: https://static-misc-3.glitch.me/leaky-resize-observer/

The same happens with IntersectionObserver.

This seems unexpected because the element no longer has the means to resize or intersect, as it can no longer be reattached to the document. Also, MutationObserver and event listeners do not cause this sort of leak.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210620/1ec38ae0/attachment-0001.htm>


More information about the webkit-unassigned mailing list