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

Issue 2903703003: Use wrapper tracing for worklets. (Closed)

Created:
3 years, 7 months ago by majidvp
Modified:
3 years, 6 months ago
CC:
chromium-reviews, shans, rjwright, blink-reviews-animation_chromium.org, blink-reviews, darktears, Eric Willigers, ikilpatrick
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Use wrapper tracing for worklets. Many worklet provide a way for scripts to register components (e.g., paint, animator, processor) in the worklet global scope. These components own v8 objects so they should participate in wrapper tracing to ensure accurate and timely garbage collection. This depends on having worklet global scope ActiveScriptWrappable which is here: https://chromium-review.googlesource.com/c/522169/ BUG=726457 Review-Url: https://codereview.chromium.org/2903703003 Cr-Commit-Position: refs/heads/master@{#477275} Committed: https://chromium.googlesource.com/chromium/src/+/303c5ab1608b16d3e4b793557718b3666a720fff

Patch Set 1 #

Total comments: 4

Patch Set 2 : fix comments #

Total comments: 2

Patch Set 3 : Address feedback & convert paint/audio worklets #

Patch Set 4 : Ensure worklet global scope is actually traced #

Patch Set 5 : rebase #

Total comments: 1

Patch Set 6 : Separating in two CLs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+131 lines, -71 lines) Patch
M third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.h View 1 3 chunks +7 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp View 1 2 3 chunks +16 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/modules/compositorworker/Animator.h View 1 2 2 chunks +9 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/modules/compositorworker/Animator.cpp View 1 2 2 chunks +6 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.h View 1 2 chunks +8 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/modules/compositorworker/AnimatorDefinition.cpp View 1 chunk +7 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.h View 1 2 4 chunks +11 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp View 1 2 2 chunks +9 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.h View 1 2 3 4 3 chunks +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp View 1 2 3 4 3 chunks +8 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h View 1 2 4 chunks +6 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.cpp View 1 2 4 chunks +15 lines, -9 lines 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.h View 1 2 3 chunks +6 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp View 1 2 2 chunks +5 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.h View 1 2 4 chunks +7 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.cpp View 1 2 2 chunks +7 lines, -2 lines 0 comments Download

Messages

Total messages: 43 (26 generated)
majidvp
mlippautz@: Can you please take a look and let me know if the general approach ...
3 years, 7 months ago (2017-05-24 14:34:56 UTC) #4
Michael Lippautz
+haraken for a general review. Wrapper tracing looks good % comments. https://codereview.chromium.org/2903703003/diff/1/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp File third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp (right): ...
3 years, 7 months ago (2017-05-24 14:42:44 UTC) #6
haraken
LGTM https://codereview.chromium.org/2903703003/diff/20001/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.h File third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.h (right): https://codereview.chromium.org/2903703003/diff/20001/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.h#newcode49 third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.h:49: AnimatorList animators_; Do you need to trace both ...
3 years, 7 months ago (2017-05-25 04:22:12 UTC) #11
majidvp
https://codereview.chromium.org/2903703003/diff/1/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp File third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp (right): https://codereview.chromium.org/2903703003/diff/1/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp#newcode54 third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp:54: visitor->TraceWrappers(definition.value); On 2017/05/24 14:42:43, Michael Lippautz wrote: > Missing ...
3 years, 6 months ago (2017-05-25 20:16:57 UTC) #15
haraken
On 2017/05/25 20:16:57, majidvp wrote: > https://codereview.chromium.org/2903703003/diff/1/third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp > File > third_party/WebKit/Source/modules/compositorworker/AnimationWorkletGlobalScope.cpp > (right): > > ...
3 years, 6 months ago (2017-05-26 02:14:54 UTC) #18
majidvp
haraken@, mlippautz@: I wonder if you know the answer to this. The current patch adds ...
3 years, 6 months ago (2017-05-31 19:20:37 UTC) #19
Michael Lippautz
On 2017/05/31 19:20:37, majidvp wrote: > haraken@, mlippautz@: I wonder if you know the answer ...
3 years, 6 months ago (2017-05-31 20:06:39 UTC) #20
haraken
On 2017/05/31 20:06:39, Michael Lippautz wrote: > On 2017/05/31 19:20:37, majidvp wrote: > > haraken@, ...
3 years, 6 months ago (2017-06-01 02:05:27 UTC) #21
majidvp
On 2017/06/01 02:05:27, haraken wrote: > On 2017/05/31 20:06:39, Michael Lippautz wrote: > > On ...
3 years, 6 months ago (2017-06-01 19:42:37 UTC) #28
majidvp
haraken@ PTAL
3 years, 6 months ago (2017-06-01 19:42:59 UTC) #29
haraken
Would it be possible to split the patch into two parts? - Make GlobalScopes ActiveScriptWrappable ...
3 years, 6 months ago (2017-06-02 02:32:25 UTC) #32
majidvp
On 2017/06/02 02:32:25, haraken wrote: > Would it be possible to split the patch into ...
3 years, 6 months ago (2017-06-02 17:52:41 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2903703003/100001
3 years, 6 months ago (2017-06-06 12:14:34 UTC) #37
commit-bot: I haz the power
Committed patchset #6 (id:100001) as https://chromium.googlesource.com/chromium/src/+/303c5ab1608b16d3e4b793557718b3666a720fff
3 years, 6 months ago (2017-06-06 13:55:39 UTC) #40
haraken
On 2017/06/01 02:05:27, haraken wrote: > On 2017/05/31 20:06:39, Michael Lippautz wrote: > > On ...
3 years, 6 months ago (2017-06-21 12:06:17 UTC) #41
Michael Lippautz
On 2017/06/21 12:06:17, haraken wrote: > On 2017/06/01 02:05:27, haraken wrote: > > On 2017/05/31 ...
3 years, 6 months ago (2017-06-21 19:26:47 UTC) #42
haraken
3 years, 6 months ago (2017-06-22 02:39:09 UTC) #43
Message was sent while issue was closed.
On 2017/06/21 19:26:47, Michael Lippautz wrote:
> On 2017/06/21 12:06:17, haraken wrote:
> > On 2017/06/01 02:05:27, haraken wrote:
> > > On 2017/05/31 20:06:39, Michael Lippautz wrote:
> > > > On 2017/05/31 19:20:37, majidvp wrote:
> > > > > haraken@, mlippautz@: I wonder if you know the answer to this.
> > > > > 
> > > > > The current patch adds wrapper tracing for object owned by the 
> > > > > WorkletGlobalScope. But at the moment it is failing the following
> > > > > GC unit test for paint worklet: 
> > > > > PaintWorkletTest.GarbageCollectionOfCSSPaintDefinition [1]
> > > > > 
> > > > > My guess is that although we are tracing paint definitions from paint
> > > > > global scope but we never really trace the worklet global scope
itself.
> > > > > The worklet global scope is kept alive via a Persistent reference.
> > > > > 
> > > > 
> > > > Can you point me to the reference you are talking about? In general:
> > > > v8::Persistent don't provide entry points into the graph, only
> > > > blink::ScriptWrappable_s do. Now, when I initially looked at this change
I
> > saw
> > > > that WorkletGlobalScope is a ScriptWrappable, so all the
> *WorkletGlobalScope
> > > > should be too. The JS wrapper object should then be the entry point for
> > > tracing.
> > > > 
> > > > 
> > > > Another idea would be that V8's Scavenger gets rid of them because they
> are
> > > > supposedly treated as independent. Can you try adding
"DependentLifetime"
> to
> > > > WorkletGlobalScope.idl (or their more specific IDL file, e.g.
> > > > AudioWorkletGlobalScope.idl)?
> > > 
> > > I guess this could be the root cause of the failure.
> > > 
> > > We must add [DependentLifetime] on IDL files of DOM objects that have
> > > TraceWrappers or are traced by TraceWrappers. This is really error-prone
and
> > we
> > > should fix it at some point.
> > > 
> > > Michael: In short term, would it be possible to add a DCHECK to verify
that
> > DOM
> > > wrappers that have TraceWrappers or are traced by TraceWrappers are
> annotated
> > > with [DependentLifetime]?
> > 
> > ^^^ Michael: Do you have a cycle to work on the short-term fix at the
moment?
> 
> I tried last week but couldn't really find a nice spot to put it. Essentially,
> we need to allow regular tracing for those without DependentLifetime as far as
I
> can see, because V8 is just passing them over to Blink.
> 
> Thus, the check should be something along the lines
>   if (!DependentLifetime(T)) {
>    
>
DCHECK(std::is_same<decltype(&T::Foo),decltype(&TraceWrapperBase::TraceWrappers)>::value);
>   }
> 
> However, I failed to find a place where we have both, the type T, and
> WrapperTypeInfo available. There's a cyclic include between WrapperVisitor.h
and
> WrapperTypeInfo.h that would need to be resolved first, so that we can use
> WrapperTypeInfo in WrapperVisitor. 
> 
> I will dedicate another day this week for this problem. Maybe we can find a
> better way.

Thanks Michael!

We won't need to include the type T, right? To use:

  scriptWrappable->GetWrapperTypeInfo()->isDependent()

it would be enough to include ScriptWrappable.h and WrapperTypeInfo.h in
ScriptWrappableVisitor.cpp... ?

Powered by Google App Engine
This is Rietveld 408576698