WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
309699
ResizeObserver retains references to removed DOM elements without explicit unobserve() resulting in poor performance - they are GC'd in Firefox and Chrome
https://bugs.webkit.org/show_bug.cgi?id=309699
Summary
ResizeObserver retains references to removed DOM elements without explicit un...
Paul Rhomberg
Reported
2026-03-11 11:54:23 PDT
Created
attachment 478631
[details]
Minimal reproduction Resize observers don't seem to garbage collect effectively. When observing a lot of elements and removing these without calling .unobserve() on them, performance degrades. To illustrate this issue, the provided html file does the following: 1. On button click, it creates 10,000 elements 2. It observes them all with a ResizeObserver 3. When the button is clicked again, the elements get removed and new ones get created & observed While on Chrome and Firefox, this cycle can be performed hundreds of times without slowdown, on Safari, the page starts lagging drastically after ~10-20 cycles, and each cycle takes longer and longer. This indicates that Firefox and Chrome perform some sort of garbage collection even when .unobserve() is not called, whereas Safari does not. Tested on Safari 26.3.1 on iOS, iPhone 15 Pro
Attachments
Minimal reproduction
(1.09 KB, text/html)
2026-03-11 11:54 PDT
,
Paul Rhomberg
no flags
Details
rendering of timelines in webinspector for multiple clicks.
(148.27 KB, image/png)
2026-03-16 18:09 PDT
,
Karl Dubost
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2026-03-15 03:56:28 PDT
<
rdar://problem/172597260
>
Karl Dubost
Comment 2
2026-03-16 18:09:35 PDT
Created
attachment 478702
[details]
rendering of timelines in webinspector for multiple clicks. Thanks Paul. This is indeed happening. We can indeed see how the click event takes longer and longer to get dispatched.
Karl Dubost
Comment 3
2026-03-16 18:10:55 PDT
To note that the ResizeObserver callback is pretty constant around 0.113ms
Ryosuke Niwa
Comment 4
2026-03-17 01:09:24 PDT
https://commits.webkit.org/309376@main
should have addressed this issue for most part.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug