ServiceWorker WebProcess sometimes crashes in JSVMClientData::~JSVMClientData()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2017 06:13:40 +0000 (06:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2017 06:13:40 +0000 (06:13 +0000)
commit24b04f25ae6336ab4342eee01dcf1b749c98c8e8
treede8056d11c995a091acbdefb875849d4a36b1f25
parent174e573d717b755a70ab839212fee2339139661a
ServiceWorker WebProcess sometimes crashes in JSVMClientData::~JSVMClientData()
https://bugs.webkit.org/show_bug.cgi?id=180173

Reviewed by Alex Christensen.

The leak was caused by EventListeners remaining when destroying the VM, because
JSEventListener refs the DOMWrapperWorld. To address the issue, we now call
removeAllEventListeners() in the stop() method of ServiceWorkerContainer,
ServiceWorkerRegistration and ServiceWorker. Those event listeners are no
longer needed after ActiveDOMObject::stop() is called since the script
execution context is about to be destroyed.

This is the same pattern used in IDBDatabase::stop(), IDBRequest::stop().

No new tests, already covered by existing test.

* workers/service/ServiceWorker.cpp:
(WebCore::ServiceWorker::stop):
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::stop):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::stop):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorker.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp