RESOLVED FIXED 188575
[IntersectionObserver] Do not hold a strong reference to the root element
https://bugs.webkit.org/show_bug.cgi?id=188575
Summary [IntersectionObserver] Do not hold a strong reference to the root element
Ali Juma
Reported 2018-08-14 13:25:21 PDT
An IntersectionObserver should not keep its root element alive when there aren't any other references to the root.
Attachments
Patch (13.34 KB, patch)
2018-08-14 13:34 PDT, Ali Juma
no flags
Patch for landing (13.27 KB, patch)
2018-08-15 06:29 PDT, Ali Juma
no flags
Ali Juma
Comment 1 2018-08-14 13:34:31 PDT
Simon Fraser (smfr)
Comment 2 2018-08-14 16:03:01 PDT
Comment on attachment 347106 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=347106&action=review > Source/WebCore/page/IntersectionObserver.cpp:126 > + for (size_t i = 0; i < elementObservers.size(); ++i) { > + if (elementObservers.at(i) == this) { > + elementObservers.remove(i); > + break; > + } This should use removeFirst() > Source/WebCore/page/IntersectionObserver.h:43 > + Vector<IntersectionObserver*> observers; Who owns the IntersectionObservers? Would be nice for the comment to say what the ownership model is. > Source/WebCore/page/IntersectionObserver.h:75 > + Element* m_root; We should make WeakPtr work for Elements.
Ali Juma
Comment 3 2018-08-15 06:29:18 PDT
Created attachment 347159 [details] Patch for landing
Ali Juma
Comment 4 2018-08-15 06:31:22 PDT
Comment on attachment 347106 [details] Patch Thanks for the review! View in context: https://bugs.webkit.org/attachment.cgi?id=347106&action=review >> Source/WebCore/page/IntersectionObserver.cpp:126 >> + } > > This should use removeFirst() Done. >> Source/WebCore/page/IntersectionObserver.h:43 >> + Vector<IntersectionObserver*> observers; > > Who owns the IntersectionObservers? Would be nice for the comment to say what the ownership model is. Updated the comment to mention that observers are owned by JavaScript wrappers and by IntersectionObserverRegistrations for currently-observed targets (to be implemented in a future patch).
WebKit Commit Bot
Comment 5 2018-08-15 07:13:13 PDT
Comment on attachment 347159 [details] Patch for landing Clearing flags on attachment: 347159 Committed r234884: <https://trac.webkit.org/changeset/234884>
WebKit Commit Bot
Comment 6 2018-08-15 07:13:15 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 7 2018-08-15 07:15:43 PDT
Note You need to log in before you can comment on or make changes to this bug.