Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Service Workers to run for a little longer in case of functional events #635

Conversation

youennf
Copy link
Contributor

@youennf youennf commented May 16, 2022

ff2e4e4

Allow Service Workers to run for a little longer in case of functional events
https://bugs.webkit.org/show_bug.cgi?id=240454

Patch by Youenn Fablet <youennf@gmail.com > on 2022-05-17
Reviewed by Chris Dumez.

Functional events should usually trigger opening a new web page on the same origin as the service worker.
There are good chances that the service worker will control the new web page, it is thus potentially useful to
keep the service worker around for a bit, to not pay the cost of stopping and restarting it.
To do so, we introduce a timer in SWServerWorker that handles the termination in case of functional events/debugger.

Covered by updated API test.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:
* Source/WebCore/workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::startTermination):
(WebCore::SWServerWorker::shouldBeTerminated const):
(WebCore::SWServerWorker::terminateIfPossible):
(WebCore::SWServerWorker::terminationIfPossibleTimerFired):
* Source/WebCore/workers/service/server/SWServerWorker.h:

Canonical link: https://commits.webkit.org/250635@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294315 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@youennf youennf added the Service Workers Component for Service Workers bugs. label May 16, 2022
@youennf youennf requested review from cdumez and beidson May 16, 2022 15:07
@youennf youennf added the merge-queue Applied to send a pull request to merge-queue label May 17, 2022
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Allow-Service-Workers-to-run-for-a-little-longer-in-case-of-functional-events branch from d5a24f7 to ff2e4e4 Compare May 17, 2022 08:38
@webkit-early-warning-system webkit-early-warning-system merged commit ff2e4e4 into WebKit:main May 17, 2022
@webkit-early-warning-system
Copy link
Collaborator

Committed r294315 (250635@main): https://commits.webkit.org/250635@main

Reviewed commits have been landed. Closing PR #635 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Service Workers Component for Service Workers bugs.
Projects
None yet
4 participants