Design doc for overall work: https://docs.google.com/document/d/1USTH2Vd4D2tALsvZvy4B2aWotKWjkCYP5m0g7b90RAU/view This bug tracks converting PaintWorkletGlobalScope (https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h?q=PaintWorkletGlobalScope&sq=package:chromium&g=0&l=21) from a MainThreadWorkletGlobalScope into a ThreadedWorkletGlobalScope so that it can be used on the AnimationWorklet thread. There are two main parts to this: 1. First make the change, but have the PaintWorkletGlobalScope still running on main (e.g. the underling PaintWorkletThread would have a backing-thread that is the main thread). The difficulty here is making sure that ThreadedWorkletGlobalScope interacts correctly when running on main, that console logs, devtools, and exceptions continue to function. 2. Do the extra work to allow choosing whether to run PaintWorkletGlobalScope on main or on a background thread (e.g. AnimationWorklet thread). This part should actually be easier, will just involve the rest of the plumbing. Most of #2 is done in the prototype (https://chromium-review.googlesource.com/c/chromium/src/+/1251465), but we skipped over #1 in order to get it working.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7 commit 56ba112bc282859d2ef2e3ed1b54a931da3c3ef7 Author: Stephen McGruer <smcgruer@chromium.org> Date: Tue Oct 23 20:42:39 2018 First steps to generalize AnimationWorkletThread for both worklets This CL renames AnimationWorkletThread to a new class, AnimationAndPaintWorkletThread, in preparation for doing off-thread PaintWorklet. The idea is that both AnimationWorklet and PaintWorklet will share the same thread, since both do similar operations and we don't need a separate thread for each. Bug: 890759 Change-Id: Id9c78fa726ee2c04336ffc824cf9cdff285eed5c Reviewed-on: https://chromium-review.googlesource.com/c/1286285 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Yi Gu <yigu@chromium.org> Commit-Queue: Stephen McGruer <smcgruer@chromium.org> Cr-Commit-Position: refs/heads/master@{#602076} [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/public/platform/web_thread_type.h [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/controller/blink_leak_detector.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/core/core_initializer.h [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/BUILD.gn [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/animationworklet/BUILD.gn [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/animationworklet/DEPS [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/animationworklet/animation_worklet.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope_test.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/animationworklet/animation_worklet_messaging_proxy.cc [delete] https://crrev.com/d1e8c8a3de692b19ea02c6df0140b860f1503244/third_party/blink/renderer/modules/animationworklet/animation_worklet_thread.cc [delete] https://crrev.com/d1e8c8a3de692b19ea02c6df0140b860f1503244/third_party/blink/renderer/modules/animationworklet/animation_worklet_thread.h [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/modules_initializer.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/modules_initializer.h [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/BUILD.gn [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/DEPS [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/OWNERS [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/README.md [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread.cc [add] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread.h [rename] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread_test.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/platform/scheduler/common/metrics_helper.cc [modify] https://crrev.com/56ba112bc282859d2ef2e3ed1b54a931da3c3ef7/third_party/blink/renderer/platform/web_thread_type.cc
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/5bb4a0a197893e485b318a1cc2710812cf697ea6 commit 5bb4a0a197893e485b318a1cc2710812cf697ea6 Author: Stephen McGruer <smcgruer@chromium.org> Date: Fri Nov 02 01:04:40 2018 [PaintWorklet] Initial work to thread PaintWorkletGlobalScope This CL introduces an alternative constructor for PaintWorkletGlobalScope which will make it call the threaded constructor for WorkletGlobalScope. The choice of which type to use is made in PaintWorklet::CreateGlobalScope, based on the OffMainThreadCSSPaint blink feature flag. This CL should have no behavioral change when OffMainThreadCSSPaint is not specified. Bug: 890759 Change-Id: Ie971883e605a61e13c6dcdda7ad43487d1c840bb Reviewed-on: https://chromium-review.googlesource.com/c/1273151 Commit-Queue: Stephen McGruer <smcgruer@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/master@{#604790} [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/BUILD.gn [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/BUILD.gn [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/DEPS [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/css_paint_definition.h [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet.cc [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.cc [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope.h [add] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_global_scope_test.cc [add] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_messaging_proxy.cc [add] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_messaging_proxy.h [add] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client.cc [add] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client.h [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread.cc [modify] https://crrev.com/5bb4a0a197893e485b318a1cc2710812cf697ea6/third_party/blink/renderer/modules/worklet/animation_and_paint_worklet_thread.h
I'm not aware of any further work required here; PaintWorkletGlobalScope can now be used either on the main thread or on a worklet thread.
Comment 1 by smcgruer@chromium.org
, Oct 1