New issue
Advanced search Search tips

Issue 694914 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Task

Blocked on:
issue 696905

Blocking:
issue 694925



Sign in to add a comment

Provide saner and more consistent postTask interfaces for worker threads

Project Member Reported by nhiroki@chromium.org, Feb 22 2017

Issue description

It'd be nice if we have saner and more consistent way to access WebTaskRunners for worker threads like TaskRunnerHelper and ParentFrameTaskRunners for the main thread.

This would be helpful...

- for avoiding accessing a per-thread heap objects from a foreign thread. For example, (indirectly) retaining a reference to ExecutionContext is a common way to post a task to that context thread, but this would be error-prone and not encouraged ( issue 673711 ).
- for introducing task priority / throttling mechanism ( issue 670534 ).
 
Blockedon: 694925
POC patch doesn't work because of  issue 694925 . WorkerOrWorkletGlobalScope::postTask() expects that it's called from the main thread or a worker thread, but it can be called from another thread (maybe IO thread?)
Project Member

Comment 3 by bugdroid1@chromium.org, Feb 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/98eb8962d85b8c426602f89e6e31358b40e46bab

commit 98eb8962d85b8c426602f89e6e31358b40e46bab
Author: nhiroki <nhiroki@chromium.org>
Date: Sat Feb 25 17:02:49 2017

Worker: Pass ParentFrameTaskRunners via WorkerThread::start() instead of the ctor

This is a cleanup and should not change behavior.

ParentFrameTaskRunners is never used before WorkerThread::start() is called so
we don't have to pass it via the ctor of WorkerThread. This drastically
simplifies code and enables us to modify thread infra with a smaller number of
file changes.

BUG= 694914 

Review-Url: https://codereview.chromium.org/2718643002
Cr-Commit-Position: refs/heads/master@{#453096}

[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/DedicatedWorkerMessagingProxy.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/DedicatedWorkerThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/DedicatedWorkerThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/SharedWorkerThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/WorkerThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletMessagingProxy.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThreadTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerMessagingProxy.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/webaudio/AudioWorkletThread.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/webaudio/AudioWorkletThread.h
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/modules/webaudio/AudioWorkletThreadTest.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/98eb8962d85b8c426602f89e6e31358b40e46bab/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Blockedon: 696905
Status: Started (was: Assigned)
I'm now trying another approach:
https://codereview.chromium.org/2806623004/
Blocking: 694925
Blockedon: -694925
Project Member

Comment 8 by bugdroid1@chromium.org, Apr 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d56a35fb25dc388a0506174b9e3fda67337313ce

commit d56a35fb25dc388a0506174b9e3fda67337313ce
Author: nhiroki <nhiroki@chromium.org>
Date: Thu Apr 20 01:05:33 2017

Worker: Introduce per-global-scope task scheduler

This CL introduces WorkerGlobalScopeScheduler to make it simpler and saner to
manage tasks on worker threads.

Before this CL, tasks on worker threads were always pushed into the thread's
default task queue, they should be handled in different ways based on their
task types though. For example, worker tasks shouldn't run after the global
scope is closed, while thread control tasks should run even after that. To
achieve it, worker tasks were always wrapped with WorkerThread's method to check
the current thread state. This was so tricky.

After this CL, each global scope has its own task queues like per-frame task
scheduler. Worker tasks are pushed into the task queues, control tasks are still
pushed into the thread's default task queue though. Thanks to this separation,
we can abort only worker tasks by simply unregistering the queues when a global
scope is closed.

In addition, this CL unifies postTask interfaces into TaskRunnerHelper (issue
694914), and enables any threads to post a task to worker threads because of
thread-safe refcounted WebTaskRunner.

BUG= 670534 ,  694914 ,  710364 

Review-Url: https://codereview.chromium.org/2806623004
Cr-Commit-Position: refs/heads/master@{#465841}

[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/dom/TaskRunnerHelper.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/core/workers/WorkerThread.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/modules/time_zone_monitor/TimeZoneMonitorClient.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScopeTest.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/web_task_runner_impl.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/webthread_base.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.h
[add] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.cc
[add] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
[add] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler_unittest.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.cc
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.h
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/d56a35fb25dc388a0506174b9e3fda67337313ce/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Labels: -Type-Bug M-60 Type-Task
Status: Fixed (was: Started)
Now TaskRunnerHelper is available for posting a task to worker threads.
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ee6a4f06b0e0561618669ed56e5997af91108c3e

commit ee6a4f06b0e0561618669ed56e5997af91108c3e
Author: aboxhall <aboxhall@chromium.org>
Date: Thu Apr 20 03:46:24 2017

Revert of Worker: Introduce per-global-scope task scheduler (patchset #22 id:450001 of https://codereview.chromium.org/2806623004/ )

Reason for revert:
Seems to have caused a crash in fast/workers/termination-early.html on Webkit Linux Trusty Leak -
https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_Trusty_Leak/4107/layout-test-results/results.html
https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/4107

https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_Trusty_Leak/4106/layout-test-results/fast/workers/termination-early-crash-log.txt
https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/4106

Original issue's description:
> Worker: Introduce per-global-scope task scheduler
>
> This CL introduces WorkerGlobalScopeScheduler to make it simpler and saner to
> manage tasks on worker threads.
>
> Before this CL, tasks on worker threads were always pushed into the thread's
> default task queue, they should be handled in different ways based on their
> task types though. For example, worker tasks shouldn't run after the global
> scope is closed, while thread control tasks should run even after that. To
> achieve it, worker tasks were always wrapped with WorkerThread's method to check
> the current thread state. This was so tricky.
>
> After this CL, each global scope has its own task queues like per-frame task
> scheduler. Worker tasks are pushed into the task queues, control tasks are still
> pushed into the thread's default task queue though. Thanks to this separation,
> we can abort only worker tasks by simply unregistering the queues when a global
> scope is closed.
>
> In addition, this CL unifies postTask interfaces into TaskRunnerHelper (issue
> 694914), and enables any threads to post a task to worker threads because of
> thread-safe refcounted WebTaskRunner.
>
> BUG= 670534 ,  694914 ,  710364 
>
> Review-Url: https://codereview.chromium.org/2806623004
> Cr-Commit-Position: refs/heads/master@{#465841}
> Committed: https://chromium.googlesource.com/chromium/src/+/d56a35fb25dc388a0506174b9e3fda67337313ce

TBR=kinuko@chromium.org,haraken@chromium.org,tzik@chromium.org,skyostil@chromium.org,altimin@chromium.org,nhiroki@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 670534 ,  694914 ,  710364 

Review-Url: https://codereview.chromium.org/2831843002
Cr-Commit-Position: refs/heads/master@{#465892}

[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/dom/TaskRunnerHelper.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/core/workers/WorkerThread.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/modules/time_zone_monitor/TimeZoneMonitorClient.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScopeTest.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/web_task_runner_impl.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/webthread_base.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.h
[delete] https://crrev.com/c695cc71ebc3348aa9db521f7f4324502a0134e3/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.cc
[delete] https://crrev.com/c695cc71ebc3348aa9db521f7f4324502a0134e3/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
[delete] https://crrev.com/c695cc71ebc3348aa9db521f7f4324502a0134e3/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler_unittest.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.cc
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.h
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/ee6a4f06b0e0561618669ed56e5997af91108c3e/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Project Member

Comment 11 by bugdroid1@chromium.org, Apr 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7800a474d39eacc36c6c247f6a956e15f5d2489a

commit 7800a474d39eacc36c6c247f6a956e15f5d2489a
Author: nhiroki <nhiroki@chromium.org>
Date: Thu Apr 20 10:06:51 2017

Reland of Worker: Introduce per-global-scope task scheduler

I couldn't reproduce the failure on my local machine and trybots.
If this still fails the tests only on the specific bot, I'll mark them with
SKIP and fix them in a separate CL.

Original issue's description:
> Revert of Worker: Introduce per-global-scope task scheduler (patchset #22 id:450001 of https://codereview.chromium.org/2806623004/ )
>
> Reason for revert:
> Seems to have caused a crash in fast/workers/termination-early.html on Webkit Linux Trusty Leak -
> https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_Trusty_Leak/4107/layout-test-results/results.html
> https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/4107
>
> https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_Trusty_Leak/4106/layout-test-results/fast/workers/termination-early-crash-log.txt
> https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/4106
>
> Original issue's description:
> > Worker: Introduce per-global-scope task scheduler
> >
> > This CL introduces WorkerGlobalScopeScheduler to make it simpler and saner to
> > manage tasks on worker threads.
> >
> > Before this CL, tasks on worker threads were always pushed into the thread's
> > default task queue, they should be handled in different ways based on their
> > task types though. For example, worker tasks shouldn't run after the global
> > scope is closed, while thread control tasks should run even after that. To
> > achieve it, worker tasks were always wrapped with WorkerThread's method to check
> > the current thread state. This was so tricky.
> >
> > After this CL, each global scope has its own task queues like per-frame task
> > scheduler. Worker tasks are pushed into the task queues, control tasks are still
> > pushed into the thread's default task queue though. Thanks to this separation,
> > we can abort only worker tasks by simply unregistering the queues when a global
> > scope is closed.
> >
> > In addition, this CL unifies postTask interfaces into TaskRunnerHelper (issue
> > 694914), and enables any threads to post a task to worker threads because of
> > thread-safe refcounted WebTaskRunner.
> >
> > BUG= 670534 ,  694914 ,  710364 
> >
> > Review-Url: https://codereview.chromium.org/2806623004
> > Cr-Commit-Position: refs/heads/master@{#465841}
> > Committed: https://chromium.googlesource.com/chromium/src/+/d56a35fb25dc388a0506174b9e3fda67337313ce
>
> TBR=kinuko@chromium.org,haraken@chromium.org,tzik@chromium.org,skyostil@chromium.org,altimin@chromium.org,nhiroki@chromium.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG= 670534 ,  694914 ,  710364 
>
> Review-Url: https://codereview.chromium.org/2831843002
> Cr-Commit-Position: refs/heads/master@{#465892}
> Committed: https://chromium.googlesource.com/chromium/src/+/ee6a4f06b0e0561618669ed56e5997af91108c3e

TBR=kinuko@chromium.org,haraken@chromium.org,tzik@chromium.org,skyostil@chromium.org,altimin@chromium.org,aboxhall@chromium.org
BUG= 670534 ,  694914 ,  710364 

Review-Url: https://codereview.chromium.org/2832763002
Cr-Commit-Position: refs/heads/master@{#465962}

[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/WorkerEventQueue.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/core/workers/WorkerThread.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/modules/time_zone_monitor/TimeZoneMonitorClient.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScopeTest.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/BUILD.gn
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/web_task_runner_impl.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/webthread_base.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/webthread_impl_for_worker_scheduler.h
[add] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.cc
[add] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
[add] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler_unittest.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.cc
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/platform/scheduler/child/worker_scheduler_impl.h
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/7800a474d39eacc36c6c247f6a956e15f5d2489a/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Project Member

Comment 12 by bugdroid1@chromium.org, Apr 21 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/156f6edd319292215ac0d8a72863cf4ae6cded7e

commit 156f6edd319292215ac0d8a72863cf4ae6cded7e
Author: nhiroki <nhiroki@chromium.org>
Date: Fri Apr 21 10:16:49 2017

Worker: Remove cross-thread PostTask functions from WorkerLoaderProxy

For cleanup, this CL replaces WorkerLoaderProxy's PostTask functions with
WebTaskRunner.

Following CLs will more clean up or remove WorkerLoaderProxy.

BUG= 694914 

Review-Url: https://codereview.chromium.org/2811993007
Cr-Commit-Position: refs/heads/master@{#466300}

[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
[modify] https://crrev.com/156f6edd319292215ac0d8a72863cf4ae6cded7e/third_party/WebKit/Source/web/WebSharedWorkerImpl.h

Project Member

Comment 13 by bugdroid1@chromium.org, May 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3e327942abfd83502aa17cc59acefa6e30c91d0e

commit 3e327942abfd83502aa17cc59acefa6e30c91d0e
Author: nhiroki <nhiroki@chromium.org>
Date: Mon May 29 08:09:17 2017

Worker: Remove WorkerLoaderProxy for clean-up

For clean-up, this CL removes WorkerLoaderProxy and makes worker components
directly use ThreadableLoadingContext instead.

Before this CL WorkerLoaderProxy is used for conveying ThreadableLoadingContext
between main and worker threads, but it's no longer necessary: we can directly
pass ThreadableLoadingContext among the threads. One of the key features of
WorkerLoaderProxy was to detect worker termination on the main thread
(DetatchProvider()), but we already have a more proper way to do it
(WorkerThreadLifecycleObserver) and it's already used for loading.

BUG= 694914 

Review-Url: https://codereview.chromium.org/2840473002
Cr-Commit-Position: refs/heads/master@{#475308}

[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/BUILD.gn
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/DedicatedWorkerMessagingProxy.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/DedicatedWorkerThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/DedicatedWorkerThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/SharedWorkerThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/SharedWorkerThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
[delete] https://crrev.com/28307e4e66a5ed3bef0c6dde62995a0fd8625799/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.cpp
[delete] https://crrev.com/28307e4e66a5ed3bef0c6dde62995a0fd8625799/third_party/WebKit/Source/core/workers/WorkerLoaderProxy.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/WorkerThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/WorkerThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletMessagingProxy.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThreadTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerMessagingProxy.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/webaudio/AudioWorkletThread.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/webaudio/AudioWorkletThread.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/webaudio/AudioWorkletThreadTest.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
[modify] https://crrev.com/3e327942abfd83502aa17cc59acefa6e30c91d0e/third_party/WebKit/Source/web/WebSharedWorkerImpl.h

Sign in to add a comment