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

Issue 2011763002: Worker: Attempt to gracefully terminate WorkerThread as much as possible (Closed)

Created:
4 years, 7 months ago by nhiroki
Modified:
4 years, 6 months ago
Reviewers:
flackr, kinuko, yhirano
CC:
blink-reviews, blink-worker-reviews_chromium.org, chromium-reviews, falken, horo+watch_chromium.org, kinuko+worker_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@reorder_functions
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Worker: Attempt to gracefully terminate WorkerThread as much as possible Before this CL, WorkerThread::terminate() called on the main thread may forcibly terminate V8 Isolate in order to ensure that the worker thread is not blocked by JS execution and a shutdown task starts soon. This is risky because, after the forced termination, V8 APIs suddenly start to return empty handles and it may cause crashes if there are no treatments for the case. After this CL, terminate() avoids the force termination as much as possible. Instead, it posts a delayed task to terminate the isolate in case that the shutdown sequence does not start on the worker thread in a certain time period. BUG=487050 Committed: https://crrev.com/1ad17d042c96e4ca924fbd11e88813da8d5241d6 Cr-Commit-Position: refs/heads/master@{#397343}

Patch Set 1 : #

Total comments: 16

Patch Set 2 : address review comments and fix failing tests #

Patch Set 3 : fix dead lock when terminateAndWait() is called before start() or after terminate() and add more te… #

Patch Set 4 : add more test expectations and clean up #

Total comments: 4

Patch Set 5 : address review comments #

Total comments: 15

Patch Set 6 : address review comments #

Patch Set 7 : fix test expectations #

Total comments: 2

Patch Set 8 : remove termination-before-initialization cases #

Total comments: 2

Patch Set 9 : EXPECT_EQ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+359 lines, -100 lines) Patch
M third_party/WebKit/Source/core/workers/WorkerThread.h View 1 2 3 4 5 6 7 6 chunks +41 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThread.cpp View 1 2 3 4 5 6 7 11 chunks +164 lines, -59 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp View 1 2 3 4 5 6 7 8 3 chunks +154 lines, -37 lines 0 comments Download

Messages

Total messages: 40 (23 generated)
nhiroki
PTAL, thanks!
4 years, 6 months ago (2016-05-27 09:30:54 UTC) #16
yhirano
https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode62 third_party/WebKit/Source/core/workers/WorkerThread.cpp:62: class WorkerThread::ForceTerminationTask { +final https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode73 third_party/WebKit/Source/core/workers/WorkerThread.cpp:73: m_cancellableTaskFactory->cancel(); Is this ...
4 years, 6 months ago (2016-05-27 11:04:43 UTC) #17
nhiroki
Thank you for reviewing! Updated. https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode62 third_party/WebKit/Source/core/workers/WorkerThread.cpp:62: class WorkerThread::ForceTerminationTask { On ...
4 years, 6 months ago (2016-05-30 06:18:47 UTC) #19
nhiroki
+flackr, could you take a look at https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode439 ? Thanks.
4 years, 6 months ago (2016-05-30 06:19:09 UTC) #21
flackr
https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode439 third_party/WebKit/Source/core/workers/WorkerThread.cpp:439: m_scheduledForceTerminationTask = ForceTerminationTask::create(this); On 2016/05/30 at 06:18:47, nhiroki wrote: ...
4 years, 6 months ago (2016-05-30 14:41:38 UTC) #22
nhiroki
https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/220001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode439 third_party/WebKit/Source/core/workers/WorkerThread.cpp:439: m_scheduledForceTerminationTask = ForceTerminationTask::create(this); On 2016/05/30 14:41:38, flackr wrote: > ...
4 years, 6 months ago (2016-05-30 22:15:12 UTC) #23
yhirano
lgtm https://codereview.chromium.org/2011763002/diff/300001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/300001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode93 third_party/WebKit/Source/core/workers/WorkerThread.cpp:93: m_workerThread->m_workerGlobalScope->scriptController()->willScheduleExecutionTermination(); [optional] It might be good to make ...
4 years, 6 months ago (2016-05-31 04:48:08 UTC) #24
nhiroki
Thank you! Updated. https://codereview.chromium.org/2011763002/diff/300001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/300001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode93 third_party/WebKit/Source/core/workers/WorkerThread.cpp:93: m_workerThread->m_workerGlobalScope->scriptController()->willScheduleExecutionTermination(); On 2016/05/31 04:48:07, yhirano wrote: ...
4 years, 6 months ago (2016-05-31 06:08:56 UTC) #26
kinuko
https://codereview.chromium.org/2011763002/diff/340001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/340001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode56 third_party/WebKit/Source/core/workers/WorkerThread.cpp:56: const long long kForceTerminationDelayInMs = 3000; // 3 secs ...
4 years, 6 months ago (2016-05-31 10:13:26 UTC) #27
nhiroki
Thanks for your comments. Updated. https://codereview.chromium.org/2011763002/diff/340001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/340001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode56 third_party/WebKit/Source/core/workers/WorkerThread.cpp:56: const long long kForceTerminationDelayInMs ...
4 years, 6 months ago (2016-06-01 04:16:36 UTC) #28
kinuko
https://codereview.chromium.org/2011763002/diff/380001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/380001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode346 third_party/WebKit/Source/core/workers/WorkerThread.cpp:346: if (!m_started) I wonder if we should just DCHECK(m_started) ...
4 years, 6 months ago (2016-06-02 02:31:29 UTC) #29
nhiroki
Thank you! Updated. https://codereview.chromium.org/2011763002/diff/380001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2011763002/diff/380001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode346 third_party/WebKit/Source/core/workers/WorkerThread.cpp:346: if (!m_started) On 2016/06/02 02:31:28, kinuko ...
4 years, 6 months ago (2016-06-02 06:20:20 UTC) #31
kinuko
lgtm https://codereview.chromium.org/2011763002/diff/420001/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp File third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp (right): https://codereview.chromium.org/2011763002/diff/420001/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp#newcode128 third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp:128: EXPECT_TRUE(WorkerThread::ExitCode::GracefullyTerminated == exitCode); nit: EXPECT_EQ
4 years, 6 months ago (2016-06-02 07:25:08 UTC) #32
nhiroki
https://codereview.chromium.org/2011763002/diff/420001/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp File third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp (right): https://codereview.chromium.org/2011763002/diff/420001/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp#newcode128 third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp:128: EXPECT_TRUE(WorkerThread::ExitCode::GracefullyTerminated == exitCode); On 2016/06/02 07:25:08, kinuko wrote: > ...
4 years, 6 months ago (2016-06-02 07:35:52 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2011763002/440001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2011763002/440001
4 years, 6 months ago (2016-06-02 07:36:39 UTC) #36
commit-bot: I haz the power
Committed patchset #9 (id:440001)
4 years, 6 months ago (2016-06-02 09:13:14 UTC) #38
commit-bot: I haz the power
4 years, 6 months ago (2016-06-02 09:14:59 UTC) #40
Message was sent while issue was closed.
Patchset 9 (id:??) landed as
https://crrev.com/1ad17d042c96e4ca924fbd11e88813da8d5241d6
Cr-Commit-Position: refs/heads/master@{#397343}

Powered by Google App Engine
This is Rietveld 408576698