New issue
Advanced search Search tips

Issue 828487 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature

Blocking:
issue 430155
issue 837287



Sign in to add a comment

AnimationWorklet - Support option bag as constructor argument for Worklet Animation

Project Member Reported by majidvp@chromium.org, Apr 3 2018

Issue description

AnimatonWorklet specification calls for an options arguments to WorkletAnimation constructor. This dictionary get structured cloned and passed to the animation instance during its construction in the worklet context. [1]

This options will allow main thread to pass in additional parameters to the worklet animation instance.


[1] https://wicg.github.io/animation-worklet/#dom-workletanimation-workletanimation

 
Cc: flackr@chromium.org
As promised here is some details on how I think this can be implemented.


## Blink side: 
- Make blink::WorkletAnimation accept an options object
  - Serialize the object using structured clonable algorithm, See SerializedScriptValue::Serialize()

## Plumbing to cc:
- Introduce a cc::WorkletAnimationOptions class which acts as an opaque handle for options.
  There will be an implementation of this in Blink which actually hold the serialized value
 e.g., cc::WorkletAnimationOptions  <-(inherits)-- blink::WorkletAnimationOptions -(owns)->blink::SerializedScriptValue  
- cc:WorkletAnimation, and its wrapper (CompositorAnimation) should accept cc:WorkletAnimationOptions
- blink wraps the serialized value in a blink::WorkletAnimationOptions and passes it to cc side

## Plumbing to worklet:
- Introduce cc::WorkletAnimationOption as a field inside MutatorInputState::AnimationState.
- Start collecting the options into the input state during  AnimationHost::CollectAnimatorsState()

Note: This is actually inefficient since it means we are including the options in every animation update we send to worklet. We have a TODO [1] to have separate structs for starting, running, finishing animations. Once that is in place, then we only need to include this value for starting animations.


## Worklet side:
- Inside AnimationWorkletGlobalScope::Mutate, we need to cast cc::WorkletAnimationOptions to
  blink::WorkletAnimationOptions and then access the serialized value.
- Then when calling the constructor, deserialize the options and pass it to the constructor. 
  See:  AnimationWorkletGlobalScope::CreateInstance()


jbroman@ is the right person to talk to validate this is actually how you can serialize/deserialize the options value.

[1] https://codesearch.chromium.org/chromium/src/cc/trees/layer_tree_mutator.h?type=cs&q=MutatorInputState&l=18

Comment 2 by yigu@chromium.org, Apr 26 2018

Blocking: 837287
Project Member

Comment 3 by bugdroid1@chromium.org, Jun 1 2018

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

commit a5a3bb6c84802e6b2087b80a8553624994080a0a
Author: Yi Gu <yigu@chromium.org>
Date: Fri Jun 01 22:16:07 2018

Introduce option as constructor argument for worklet animation

AnimatonWorklet specification calls for an options argument to
WorkletAnimation constructor. This dictionary gets structured cloned and
passed to the animation instance during its construction in the worklet
context. [1]

The options will allow main thread to pass in additional parameters to
the worklet animation instance.

See the following doc for more details.
https://docs.google.com/document/d/11Z7w9P6GJ1u6HEZJOS6BWLzb6SmmoYwRqATqXEPKFEc/edit?usp=sharing

[1] https://wicg.github.io/animation-worklet/#dom-workletanimation-workletanimation

Bug:  828487 
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ifc36e4b90768ea7b37d0fc8d3b2e6f0801f9b379
Reviewed-on: https://chromium-review.googlesource.com/1069211
Commit-Queue: Yi Gu <yigu@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563826}
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/BUILD.gn
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/animation/DEPS
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/animation/animation_host.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/animation/worklet_animation.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/animation/worklet_animation.h
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/animation/worklet_animation_unittest.cc
[add] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/trees/animation_options.h
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/trees/layer_tree_mutator.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/cc/trees/layer_tree_mutator.h
[add] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/WebKit/LayoutTests/virtual/threaded/fast/animationworklet/animation-worklet-animator-with-options-expected.txt
[add] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/WebKit/LayoutTests/virtual/threaded/fast/animationworklet/animation-worklet-animator-with-options.html
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/BUILD.gn
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope.h
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope_test.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/worklet_animation.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/worklet_animation.h
[add] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/worklet_animation_options.cc
[add] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/modules/animationworklet/worklet_animation_options.h
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/platform/animation/compositor_animation.cc
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/renderer/platform/animation/compositor_animation.h
[modify] https://crrev.com/a5a3bb6c84802e6b2087b80a8553624994080a0a/third_party/blink/tools/audit_non_blink_usage.py

Comment 4 by yigu@chromium.org, Jun 1 2018

Status: Fixed (was: Assigned)

Sign in to add a comment