We should be able to terminate service workers that are unresponsive
https://bugs.webkit.org/show_bug.cgi?id=181563
<rdar://problem/
35280031>
Reviewed by Alex Christensen.
Source/WebCore:
Test: http/tests/workers/service/postmessage-after-terminating-hung-worker.html
* workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::terminateWorker):
Before calling WorkerThread::stop(), set a timer with the given timeout parameter.
If the worker thread has not stopped when the timer fires, forcefully exit the
service worker process. The StorageProcess will take care of relaunching the
service worker process if it exits abruptly.
(WebCore::SWContextManager::serviceWorkerFailedToTerminate):
Log error message if we failed to terminate a service worker and call exit().
(WebCore::SWContextManager::ServiceWorkerTerminationRequest::ServiceWorkerTerminationRequest):
* workers/service/context/SWContextManager.h:
Source/WebKit:
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::terminateWorker):
Use a 10 second timeout for forcefully exiting the service worker process when
the service worker in question fails to terminate.
(WebKit::WebSWContextManagerConnection::syncTerminateWorker):
Use a 100ms timeout for forcefully exiting the service worker process when
the service worker in question fails to terminate. This method is only called
from the layout tests, which is why we use a very short timeout.
Source/WTF:
* wtf/ObjectIdentifier.h:
(WTF::ObjectIdentifier::loggingString const):
Allow using loggingString() from RELEASE_LOG().
LayoutTests:
Add layout test coverage.
* http/tests/workers/service/postmessage-after-terminating-hung-worker-expected.txt: Added.
* http/tests/workers/service/postmessage-after-terminating-hung-worker.html: Added.
* http/tests/workers/service/resources/postmessage-after-terminating-hung-worker.js: Added.
* http/tests/workers/service/resources/postmessage-echo-worker-mayhang.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227174
268f45cc-cd09-0410-ab3c-
d52691b4dbfc