|
|
Chromium Code Reviews|
Created:
3 years, 10 months ago by shimazu Modified:
3 years, 10 months ago Reviewers:
falken CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, shimazu+serviceworker_chromium.org, serviceworker-reviews, jam, nhiroki, kinuko+serviceworker, horo+watch_chromium.org, darin-cc_chromium.org, kinuko+watch, tzik, blink-worker-reviews_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionServiceWorker: ignore AddMessageToConsole before process allocation
This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process
is allocated.
When test is finishing, a renderer process on which the worker's script loading
is running is killed. This cancels the ServiceWorkerWriteToCacheJob
URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls
EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing,
ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a
situation that EmbeddedWorkerInstance is in the STARTING state, due to the
restart behavior of Stop, but not yet have a process when AddMessageToConsole is
called. So AddMessageToConsole would crash.
BUG=692439
Review-Url: https://codereview.chromium.org/2703153002
Cr-Commit-Position: refs/heads/master@{#451733}
Committed: https://chromium.googlesource.com/chromium/src/+/acc713786ac1643648471dd35083ce760dcdfd30
Patch Set 1 #
Total comments: 6
Patch Set 2 : Addressed falken@'s comment #Patch Set 3 : remove unnecessary if #
Total comments: 2
Patch Set 4 : Use process_id() instead of switch statement #
Messages
Total messages: 27 (15 generated)
The CQ bit was checked by shimazu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
shimazu@chromium.org changed reviewers: + falken@chromium.org
ptal
Thanks for writing the CL description but I'm a little confused: there is no SWVersion::Stop(). And I'm not sure how SWVersion::StopWorker() cancels the URLRequest, do you know how that happens? Maybe easiest to write out the sequence of events: ClearAllServiceWorkersForTest calls SWVersion::Stop(). SWVersion::Stop() cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. EmbeddedWorkerInstance may be in the STARTING state, due to the restart behavior of Stop, but not yet have a process. So AddMessageToConsole would crash. https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { can we turn this into a switch statement?
https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance_unittest.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance_unittest.cc:775: // Let StartWorker fail; binding is discarded in the middle of IPC I don't understand this comment: where is StartWorker called in lines 776-780? nit: add a period at the end of the sentence.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { On 2017/02/20 08:01:03, falken wrote: > can we turn this into a switch statement? On second thought, would it be better to just do (!client_.is_bound) { return; }? With a comment that this function can be called when the worker is not running?
Description was changed from ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. This situation happens when SWVersion::Stop() is forcefully called and it invokes the restart procedure. Failure of WriteToCacheJob which is calceled at the Stop() will pass the error message to the embedded worker though it's allocating a new process. Such forceful Stop() is happening at SWContextCore::ClearAllServiceWorkersForTest. BUG=692439 ========== to ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. When test is finishing, a renderer issuing the script loading request is shutted down. This cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing, ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a situation that EmbeddedWorkerInstance may be in the STARTING state, due to the restart behavior of Stop, but not yet have a process when AddMessageToConsole is called. So AddMessageToConsole would crash. BUG=692439 ==========
Description was changed from ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. When test is finishing, a renderer issuing the script loading request is shutted down. This cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing, ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a situation that EmbeddedWorkerInstance may be in the STARTING state, due to the restart behavior of Stop, but not yet have a process when AddMessageToConsole is called. So AddMessageToConsole would crash. BUG=692439 ========== to ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. When test is finishing, a renderer process on which the worker's script loading is running is killed. This cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing, ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a situation that EmbeddedWorkerInstance is in the STARTING state, due to the restart behavior of Stop, but not yet have a process when AddMessageToConsole is called. So AddMessageToConsole would crash. BUG=692439 ==========
Updated. ptal again:) https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { On 2017/02/20 08:14:45, falken wrote: > On 2017/02/20 08:01:03, falken wrote: > > can we turn this into a switch statement? > > On second thought, would it be better to just do (!client_.is_bound) { return; > }? |client_| is valid just after calling Start(), so it's not enough in this case. > With a comment that this function can be called when the worker is not running? Yes, this function can be called while starting (e.g. script loading). https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { On 2017/02/20 08:01:03, falken wrote: > can we turn this into a switch statement? Done. https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance_unittest.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance_unittest.cc:775: // Let StartWorker fail; binding is discarded in the middle of IPC On 2017/02/20 08:07:13, falken wrote: > I don't understand this comment: where is StartWorker called in lines 776-780? > > nit: add a period at the end of the sentence. Sorry, it's just my copy-and-paste failure. Fixed.
Updated. ptal again:) https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { On 2017/02/20 08:14:45, falken wrote: > On 2017/02/20 08:01:03, falken wrote: > > can we turn this into a switch statement? > > On second thought, would it be better to just do (!client_.is_bound) { return; > }? |client_| is valid just after calling Start(), so it's not enough in this case. > With a comment that this function can be called when the worker is not running? Yes, this function can be called while starting (e.g. script loading). https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance.cc:878: !HasSentStartWorker(starting_phase()))) { On 2017/02/20 08:01:03, falken wrote: > can we turn this into a switch statement? Done. https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... File content/browser/service_worker/embedded_worker_instance_unittest.cc (right): https://codereview.chromium.org/2703153002/diff/1/content/browser/service_wor... content/browser/service_worker/embedded_worker_instance_unittest.cc:775: // Let StartWorker fail; binding is discarded in the middle of IPC On 2017/02/20 08:07:13, falken wrote: > I don't understand this comment: where is StartWorker called in lines 776-780? > > nit: add a period at the end of the sentence. Sorry, it's just my copy-and-paste failure. Fixed.
The CQ bit was checked by shimazu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm https://codereview.chromium.org/2703153002/diff/40001/content/browser/service... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/40001/content/browser/service... content/browser/service_worker/embedded_worker_instance.cc:884: break; Sorry for keeping suggesting things. Would if (process_id() != kInvalidUniqueID) work also? It just seems like a tricky piece of code to put in AddMessageToConsole. Or should we just refactor it to a function HasProcess()? It's somewhat surprising this is the only place the check is needed...
The CQ bit was checked by shimazu@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from falken@chromium.org Link to the patchset: https://codereview.chromium.org/2703153002/#ps60001 (title: "Use process_id() instead of switch statement")
https://codereview.chromium.org/2703153002/diff/40001/content/browser/service... File content/browser/service_worker/embedded_worker_instance.cc (right): https://codereview.chromium.org/2703153002/diff/40001/content/browser/service... content/browser/service_worker/embedded_worker_instance.cc:884: break; On 2017/02/21 04:03:30, falken wrote: > Sorry for keeping suggesting things. Would if (process_id() != kInvalidUniqueID) > work also? It just seems like a tricky piece of code to put in > AddMessageToConsole. Or should we just refactor it to a function HasProcess()? > It's somewhat surprising this is the only place the check is needed... process_id() != kInvalidUniqueID seems much better than current if/switch. Updated, thanks!
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by shimazu@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1487669747691730,
"parent_rev": "86ff27ab575772808e4aa02430c571f770d556be", "commit_rev":
"acc713786ac1643648471dd35083ce760dcdfd30"}
Message was sent while issue was closed.
Description was changed from ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. When test is finishing, a renderer process on which the worker's script loading is running is killed. This cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing, ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a situation that EmbeddedWorkerInstance is in the STARTING state, due to the restart behavior of Stop, but not yet have a process when AddMessageToConsole is called. So AddMessageToConsole would crash. BUG=692439 ========== to ========== ServiceWorker: ignore AddMessageToConsole before process allocation This patch is to skip EmbeddedWorkerInstance::AddMessageToConsole before process is allocated. When test is finishing, a renderer process on which the worker's script loading is running is killed. This cancels the ServiceWorkerWriteToCacheJob URLRequestJob. So ServiceWorkerWriteToCacheJob::NotifyFinishedCaching() calls EmbeddedWorkerInstance::AddMessageToConsole. At the same time with finishing, ClearAllServiceWorkersForTest calls SWVersion::StopWorker. This causes a situation that EmbeddedWorkerInstance is in the STARTING state, due to the restart behavior of Stop, but not yet have a process when AddMessageToConsole is called. So AddMessageToConsole would crash. BUG=692439 Review-Url: https://codereview.chromium.org/2703153002 Cr-Commit-Position: refs/heads/master@{#451733} Committed: https://chromium.googlesource.com/chromium/src/+/acc713786ac1643648471dd35083... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/acc713786ac1643648471dd35083... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
