DocumentTimeline / CSSTransition objects are leaking on CNN.com
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 08:17:26 +0000 (08:17 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 08:17:26 +0000 (08:17 +0000)
commitbef6a0fcaf57565cebbd65699d14d76a60d394c0
treec7c14c52ff1182e66fb20f2ad1d8ff1fd23b6313
parent31ff56711701cdd02bfc01df8c0d47a3221dfb77
DocumentTimeline / CSSTransition objects are leaking on CNN.com
https://bugs.webkit.org/show_bug.cgi?id=208069
<rdar://problem/59680143>

Reviewed by Simon Fraser, Geoffrey Garen and Darin Adler.

Source/WebCore:

Test: webanimations/leak-css-animation.html

We add a test feature that lets use query the availability of a given WebAnimation by its "id" property in the WebAnimation::instances list.
We also fix some build issues that appeared with a change in UnifiedSources order.

* animation/ElementAnimationRareData.cpp:
(WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup):
* animation/ElementAnimationRareData.h:
(WebCore::ElementAnimationRareData::setAnimationsCreatedByMarkup): Deleted.
* animation/WebAnimation.h:
* testing/Internals.cpp:
(WebCore::Internals::animationWithIdExists const):
* testing/Internals.h:
* testing/Internals.idl:

Source/WTF:

If a CSSAnimation is set on an element using the `animation-name` CSS property, and later removed, it will leak due to the ListHashSet<RefPtr<CSSAnimation>>
(aka CSSAnimationCollection) member on ElementAnimationRareData being replaced to the new list, but the old list not being cleared from its members.

We fix the ListHashSet assignment operator to use swap ensuring previously held items are cleared.

* wtf/ListHashSet.h:
(WTF::=):

Tools:

Add a test that checks that a ListHashSet containing RefPtr<> types correctly calls the destructor for those items when the assignment operator is used.

* TestWebKitAPI/Tests/WTF/ListHashSet.cpp:
(TestWebKitAPI::ListHashSetReferencedItem::create):
(TestWebKitAPI::ListHashSetReferencedItem::ListHashSetReferencedItem):
(TestWebKitAPI::ListHashSetReferencedItem::~ListHashSetReferencedItem):
(TestWebKitAPI::FakeElementAnimationRareData::FakeElementAnimationRareData):
(TestWebKitAPI::FakeElementAnimationRareData::~FakeElementAnimationRareData):
(TestWebKitAPI::FakeElementAnimationRareData::collection):
(TestWebKitAPI::FakeElementAnimationRareData::setCollection):
(TestWebKitAPI::TEST):

LayoutTests:

Add a test that checks that setting a CSSAnimation on an element, waiting a frame, and removing it will not leak that CSSAnimation.

* webanimations/leak-css-animation-expected.txt: Added.
* webanimations/leak-css-animation.html: Added.
* webanimations/resources/css-animation-leak-iframe.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258826 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/webanimations/leak-css-animation-expected.txt [new file with mode: 0644]
LayoutTests/webanimations/leak-css-animation.html [new file with mode: 0644]
LayoutTests/webanimations/resources/css-animation-leak-iframe.html [new file with mode: 0644]
Source/WTF/ChangeLog
Source/WTF/wtf/ListHashSet.h
Source/WebCore/ChangeLog
Source/WebCore/animation/ElementAnimationRareData.cpp
Source/WebCore/animation/ElementAnimationRareData.h
Source/WebCore/animation/WebAnimation.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/ListHashSet.cpp