This website requires JavaScript.
Explore
Help
Sign In
nephele
/
haikuwebkit
Watch
1
Star
0
Fork
You've already forked haikuwebkit
0
Code
Issues
Releases
Activity
haiku
haikuwebkit
/
LayoutTests
/
intersection-observer
/
observer-and-callback-witho...
4 lines
101 B
Plaintext
Raw
Permalink
Normal View
History
Unescape
Escape
IntersectionObserver leaks documents https://bugs.webkit.org/show_bug.cgi?id=189128 Reviewed by Simon Fraser. Source/WebCore: Currently, Documents own IntersectionObservers while IntersectionObservers own callbacks that have strong references to Documents. To break this cycle, make Documents only have weak pointers to IntersectionObservers. Instead, manage the lifetime of an IntersectionObserver as an ActiveDOMObject, overriding hasPendingActivity to keep the observer alive while there are ongoing observations. However, there is a still a potential reference cycle. The callback keeps global references alive, so if there's a global reference to the observer in JavaScript, we have an observer->callback->observer cycle, keeping the callback (and hence the Document) alive. To break this cycle, make IntersectionObserver release the callback when its Document is stopped. With these changes, there are no longer any leaks reported with run-webkit-tests --world-leaks on LayoutTests/intersection-observer and LayoutTests/imported/w3c/web-platform-tests/intersection-observer. Tests: intersection-observer/no-document-leak.html intersection-observer/observer-and-callback-without-js-references.html * dom/Document.cpp: (WebCore::Document::addIntersectionObserver): (WebCore::Document::removeIntersectionObserver): * dom/Document.h: * dom/Element.cpp: (WebCore::Element::didMoveToNewDocument): * page/IntersectionObserver.cpp: (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::~IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::rootDestroyed): (WebCore::IntersectionObserver::createTimestamp const): (WebCore::IntersectionObserver::notify): (WebCore::IntersectionObserver::hasPendingActivity const): (WebCore::IntersectionObserver::activeDOMObjectName const): (WebCore::IntersectionObserver::canSuspendForDocumentSuspension const): (WebCore::IntersectionObserver::stop): * page/IntersectionObserver.h: (WebCore::IntersectionObserver::trackingDocument const): (WebCore::IntersectionObserver::trackingDocument): Deleted. * page/IntersectionObserver.idl: LayoutTests: * intersection-observer/no-document-leak-expected.txt: Added. * intersection-observer/no-document-leak.html: Added. * intersection-observer/observer-and-callback-without-js-references-expected.txt: Added. * intersection-observer/observer-and-callback-without-js-references.html: Added. * intersection-observer/resources/no-document-leak-frame.html: Added. Canonical link: https://commits.webkit.org/204346@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-06 13:51:24 +00:00
Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) https://bugs.webkit.org/show_bug.cgi?id=217016 Reviewed by Zalan Bujtas. Done with this command: find LayoutTests -name '*-expected.txt' | grep -v imported | xargs awk '/^CONSOLE MESSAGE:/ { next }; /^<\?xml/ { nextfile }; { print FILENAME; nextfile }' | xargs perl -i -pe 's/ +$//g' This affects many files, and it's not helpful to clog the change log with a list of them. Canonical link: https://commits.webkit.org/229803@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-27 02:15:19 +00:00
PASS IntersectionObserver callback fires even when the observer and callback have no JS references
IntersectionObserver leaks documents https://bugs.webkit.org/show_bug.cgi?id=189128 Reviewed by Simon Fraser. Source/WebCore: Currently, Documents own IntersectionObservers while IntersectionObservers own callbacks that have strong references to Documents. To break this cycle, make Documents only have weak pointers to IntersectionObservers. Instead, manage the lifetime of an IntersectionObserver as an ActiveDOMObject, overriding hasPendingActivity to keep the observer alive while there are ongoing observations. However, there is a still a potential reference cycle. The callback keeps global references alive, so if there's a global reference to the observer in JavaScript, we have an observer->callback->observer cycle, keeping the callback (and hence the Document) alive. To break this cycle, make IntersectionObserver release the callback when its Document is stopped. With these changes, there are no longer any leaks reported with run-webkit-tests --world-leaks on LayoutTests/intersection-observer and LayoutTests/imported/w3c/web-platform-tests/intersection-observer. Tests: intersection-observer/no-document-leak.html intersection-observer/observer-and-callback-without-js-references.html * dom/Document.cpp: (WebCore::Document::addIntersectionObserver): (WebCore::Document::removeIntersectionObserver): * dom/Document.h: * dom/Element.cpp: (WebCore::Element::didMoveToNewDocument): * page/IntersectionObserver.cpp: (WebCore::IntersectionObserver::IntersectionObserver): (WebCore::IntersectionObserver::~IntersectionObserver): (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::rootDestroyed): (WebCore::IntersectionObserver::createTimestamp const): (WebCore::IntersectionObserver::notify): (WebCore::IntersectionObserver::hasPendingActivity const): (WebCore::IntersectionObserver::activeDOMObjectName const): (WebCore::IntersectionObserver::canSuspendForDocumentSuspension const): (WebCore::IntersectionObserver::stop): * page/IntersectionObserver.h: (WebCore::IntersectionObserver::trackingDocument const): (WebCore::IntersectionObserver::trackingDocument): Deleted. * page/IntersectionObserver.idl: LayoutTests: * intersection-observer/no-document-leak-expected.txt: Added. * intersection-observer/no-document-leak.html: Added. * intersection-observer/observer-and-callback-without-js-references-expected.txt: Added. * intersection-observer/observer-and-callback-without-js-references.html: Added. * intersection-observer/resources/no-document-leak-frame.html: Added. Canonical link: https://commits.webkit.org/204346@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-06 13:51:24 +00:00