Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Issue 912753002: Stop Service Workers that execute JavaScript for too long. (Closed)

Created:
5 years, 10 months ago by falken
Modified:
5 years, 10 months ago
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, mlamouri+watch-content_chromium.org, tzik, serviceworker-reviews, jam, nhiroki, darin-cc_chromium.org, horo+watch_chromium.org, mkwst+moarreviews-renderer_chromium.org, kinuko+serviceworker, kinuko+watch
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Stop Service Workers that execute JavaScript for too long. The motivation behind this change is to: - not block the registration queue on a "while(true) {}" worker - mitigate SW's from eating too much CPU/battery without being stopped This adds a "ping" protocol from the browser to the worker thread. If the worker thread is busy executing JS it will fail to ack the ping. Each ping waits 30 seconds for a pong. If a pong is received, the next ping is sent after 10 seconds. Otherwise, the worker is stopped. This only stops workers that are busy executing synchronous JS. If the worker does something like repeatedly extend a Promise chain, it will still be able to ACK and live on. Remaining work is to set a time limit for an inflight request. Depends on https://codereview.chromium.org/930213002/ BUG=445150, 372436 Committed: https://crrev.com/b7f2b2f58a139038a970586c32b078b258519c5e Cr-Commit-Position: refs/heads/master@{#317745}

Patch Set 1 #

Patch Set 2 : rebase? #

Total comments: 5

Patch Set 3 : better tests #

Patch Set 4 : fix timeout value #

Total comments: 8

Patch Set 5 : sync #

Patch Set 6 : comments #

Patch Set 7 : rethink #

Unified diffs Side-by-side diffs Delta from patch set Stats (+207 lines, -18 lines) Patch
M content/browser/service_worker/embedded_worker_instance.h View 1 2 3 4 5 6 4 chunks +9 lines, -7 lines 0 comments Download
M content/browser/service_worker/embedded_worker_instance.cc View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_browsertest.cc View 1 2 3 4 5 3 chunks +87 lines, -3 lines 0 comments Download
M content/browser/service_worker/service_worker_version.h View 1 2 3 4 5 5 chunks +22 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_version.cc View 1 2 3 4 5 6 10 chunks +75 lines, -8 lines 0 comments Download
M content/common/service_worker/service_worker_messages.h View 1 2 3 4 2 chunks +7 lines, -0 lines 0 comments Download
M content/renderer/service_worker/service_worker_script_context.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M content/renderer/service_worker/service_worker_script_context.cc View 1 2 3 4 2 chunks +5 lines, -0 lines 0 comments Download
A + content/test/data/service_worker/while_true_in_install_worker.js View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
A + content/test/data/service_worker/while_true_in_install_worker.js.mock-http-headers View 1 2 0 chunks +-1 lines, --1 lines 0 comments Download
A + content/test/data/service_worker/while_true_worker.js View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
A + content/test/data/service_worker/while_true_worker.js.mock-http-headers View 1 2 0 chunks +-1 lines, --1 lines 0 comments Download

Messages

Total messages: 21 (5 generated)
falken
PTL
5 years, 10 months ago (2015-02-10 08:22:38 UTC) #2
kinuko
Looks good. Have you tried running this with actual SW? Did it work as expected ...
5 years, 10 months ago (2015-02-10 09:15:52 UTC) #3
michaeln
https://codereview.chromium.org/912753002/diff/20001/content/browser/service_worker/service_worker_version.cc File content/browser/service_worker/service_worker_version.cc (right): https://codereview.chromium.org/912753002/diff/20001/content/browser/service_worker/service_worker_version.cc#newcode819 content/browser/service_worker/service_worker_version.cc:819: SchedulePingWorker(); Would it make sense to only turn the ...
5 years, 10 months ago (2015-02-11 01:02:21 UTC) #5
falken
Just replying to comments for now. https://codereview.chromium.org/912753002/diff/20001/content/browser/service_worker/service_worker_version.cc File content/browser/service_worker/service_worker_version.cc (right): https://codereview.chromium.org/912753002/diff/20001/content/browser/service_worker/service_worker_version.cc#newcode819 content/browser/service_worker/service_worker_version.cc:819: SchedulePingWorker(); On 2015/02/11 ...
5 years, 10 months ago (2015-02-11 16:10:24 UTC) #6
falken
Status update: I tried testing some while(true) {} behavior, and sometimes we never return from ...
5 years, 10 months ago (2015-02-12 10:30:43 UTC) #7
falken
Updated. I switched to browsertest as the unittest didn't really capture the thread termination stuff. ...
5 years, 10 months ago (2015-02-17 09:22:39 UTC) #8
kinuko
On 2015/02/17 09:22:39, falken wrote: > Updated. I switched to browsertest as the unittest didn't ...
5 years, 10 months ago (2015-02-18 10:06:55 UTC) #9
falken
On 2015/02/18 10:06:55, kinuko wrote: > On 2015/02/17 09:22:39, falken wrote: > > Updated. I ...
5 years, 10 months ago (2015-02-18 10:10:34 UTC) #10
kinuko
On 2015/02/18 10:10:34, falken wrote: > On 2015/02/18 10:06:55, kinuko wrote: > > On 2015/02/17 ...
5 years, 10 months ago (2015-02-18 10:15:03 UTC) #11
kinuko
lgtm modulo nits https://codereview.chromium.org/912753002/diff/60001/content/browser/service_worker/service_worker_browsertest.cc File content/browser/service_worker/service_worker_browsertest.cc (right): https://codereview.chromium.org/912753002/diff/60001/content/browser/service_worker/service_worker_browsertest.cc#newcode81 content/browser/service_worker/service_worker_browsertest.cc:81: base::MessageLoopProxy::current())); nit: this could just call ...
5 years, 10 months ago (2015-02-18 13:06:25 UTC) #12
falken
Thanks! https://codereview.chromium.org/912753002/diff/60001/content/browser/service_worker/service_worker_browsertest.cc File content/browser/service_worker/service_worker_browsertest.cc (right): https://codereview.chromium.org/912753002/diff/60001/content/browser/service_worker/service_worker_browsertest.cc#newcode81 content/browser/service_worker/service_worker_browsertest.cc:81: base::MessageLoopProxy::current())); On 2015/02/18 13:06:24, kinuko wrote: > nit: ...
5 years, 10 months ago (2015-02-23 05:00:07 UTC) #14
falken
+tsepez: messages
5 years, 10 months ago (2015-02-23 05:00:24 UTC) #16
Tom Sepez
Messages LGTM.
5 years, 10 months ago (2015-02-23 17:49:28 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/912753002/120001
5 years, 10 months ago (2015-02-24 01:37:46 UTC) #19
commit-bot: I haz the power
Committed patchset #7 (id:120001)
5 years, 10 months ago (2015-02-24 02:42:03 UTC) #20
commit-bot: I haz the power
5 years, 10 months ago (2015-02-24 02:43:07 UTC) #21
Message was sent while issue was closed.
Patchset 7 (id:??) landed as
https://crrev.com/b7f2b2f58a139038a970586c32b078b258519c5e
Cr-Commit-Position: refs/heads/master@{#317745}

Powered by Google App Engine
This is Rietveld 408576698