[webkit-changes] [WebKit/WebKit] 42b406: REGRESSION (264242 at main): http/tests/workers/servi...

youennf noreply at github.com
Tue Jun 27 09:58:48 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 42b406d0e2bc3cf1d47684ce0b3aa900c9950f0e
      https://github.com/WebKit/WebKit/commit/42b406d0e2bc3cf1d47684ce0b3aa900c9950f0e
  Author: Youenn Fablet <youennf at gmail.com>
  Date:   2023-06-27 (Tue, 27 Jun 2023)

  Changed paths:
    M Source/WebCore/workers/service/server/SWServer.cpp
    M Source/WebCore/workers/service/server/SWServerWorker.cpp
    M Source/WebCore/workers/service/server/SWServerWorker.h

  Log Message:
  -----------
  REGRESSION (264242 at main): http/tests/workers/service/postmessage-after-terminating-hung-worker.html is frequently hitting ASSERTION FAILED: state == ServiceWorkerState::Activating
https://bugs.webkit.org/show_bug.cgi?id=258502
rdar://111299016

Reviewed by Chris Dumez.

We added support for restarting a service worker when firing the activate event.
The assertion failure is due to the following case:
1. The service worker, while installing, is set to terminating
2. The service worker finishes its install and goes to activating. We try firing the activate event but delay until the worker is terminated.
3. The service worker gets terminated. At that point, the service worker state is set to NotRunning.
3a. First we execute callbacks, which triggers running the service worker and firing the activate event synchronously.
3b. Then we check whether the worker is activating, and given it was terminated, we set it as activated in SWServerWorker::setState.
4. We receive the didFinishActivation message and hit the assert, since the worker state is already activated.

To prevent this, we add a boolean on SWServerWorker to know whether the activate event is fired.
When the worker goes in NotRunning state, we first check whether the activate event was fired.
We then run the termination callbacks.
Then, if the activatee vent was fired before the callbacks, we immediately activate the worker.
This fixes locally the ASSERT.

* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::runServiceWorkerAndFireActivateEvent):
* Source/WebCore/workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::setState):
* Source/WebCore/workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::markActivateEventAsFired):

Canonical link: https://commits.webkit.org/265553@main




More information about the webkit-changes mailing list