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

Issue 2025783002: Worker: Introduce an observation mechanism for WorkerThread termination (Closed)

Created:
4 years, 6 months ago by nhiroki
Modified:
4 years, 3 months ago
CC:
chromium-reviews, blink-reviews, kinuko+worker_chromium.org, falken, blink-worker-reviews_chromium.org, horo+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@delayed_task
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Worker: Introduce an observation mechanism for WorkerThread termination This mechanism provides a way to observe WorkerThread termination from the main thread. This is useful when an object living on the main thread needs to release references to objects on the worker thread before it gets terminated. As an example of using this mechanism, this CL applies it to WebSocket. WorkerWebSocketChannel::Peer observes worker thread termination from the main thread and asks DocumentWebSocketChannel to release references to objects on the worker thread when the termination happens. Design doc: https://docs.google.com/document/d/1rYFKem6SwghdISe_to5b4apORIKqjOpsV5FkE3f5WQ0/edit BUG=575532 Committed: https://crrev.com/ff24de0d44123ca7ae9b9511268fdd926356a36f Cr-Commit-Position: refs/heads/master@{#398886}

Patch Set 1 : #

Patch Set 2 : maybe fix tests #

Total comments: 8

Patch Set 3 : rebase #

Patch Set 4 : address review comments #

Patch Set 5 : remake and add tests #

Total comments: 16

Patch Set 6 : rebase #

Patch Set 7 : address review comments #

Patch Set 8 : update implementation comments #

Total comments: 4

Patch Set 9 : Stop tracing CrossThread(Weak)Persistents #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+182 lines, -17 lines) Patch
M third_party/WebKit/Source/core/core.gypi View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThread.h View 1 2 3 4 5 6 7 8 4 chunks +24 lines, -0 lines 2 comments Download
M third_party/WebKit/Source/core/workers/WorkerThread.cpp View 1 2 3 4 5 6 7 8 3 chunks +22 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h View 1 2 3 4 5 6 1 chunk +44 lines, -0 lines 1 comment Download
A third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.cpp View 1 2 3 4 1 chunk +20 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp View 1 2 3 4 4 chunks +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h View 1 2 3 4 5 6 2 chunks +11 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h View 1 2 3 4 5 6 5 chunks +12 lines, -6 lines 2 comments Download
M third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp View 1 2 3 4 5 6 7 8 7 chunks +37 lines, -11 lines 1 comment Download
M third_party/WebKit/Source/platform/CrossThreadCopier.h View 1 2 3 4 5 6 1 chunk +5 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 60 (26 generated)
nhiroki
Hi yhirano@, can you give me your early feedback on this? If this looks good ...
4 years, 6 months ago (2016-06-03 01:34:24 UTC) #15
yhirano
https://codereview.chromium.org/2025783002/diff/180001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h File third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h (right): https://codereview.chromium.org/2025783002/diff/180001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h#newcode16 third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h:16: class CORE_EXPORT WorkerThreadLifecycleObserver : public LifecycleObserver<WorkerThreadContext, WorkerThreadLifecycleObserver> { +comments ...
4 years, 6 months ago (2016-06-03 07:40:37 UTC) #17
nhiroki
Thank you for reviewing! Can you take another look? As we chatted offline, the latest ...
4 years, 6 months ago (2016-06-08 09:17:45 UTC) #18
yhirano
https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h File third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h (right): https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h#newcode36 third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h:36: }; no semicolon https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h File third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h (right): https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h#newcode76 third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h:76: ...
4 years, 6 months ago (2016-06-09 04:55:13 UTC) #19
nhiroki
Thank you for reviewing! Updated. https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h File third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h (right): https://codereview.chromium.org/2025783002/diff/240001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h#newcode36 third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h:36: }; On 2016/06/09 04:55:13, ...
4 years, 6 months ago (2016-06-09 07:37:07 UTC) #20
nhiroki
+hiroshige, can you review CrossThreadCopier.h? Thanks!
4 years, 6 months ago (2016-06-09 07:38:33 UTC) #22
yhirano
lgtm, thank you!
4 years, 6 months ago (2016-06-09 08:50:32 UTC) #23
nhiroki
+haraken@, can you review core/ and platform/? Thanks!
4 years, 6 months ago (2016-06-09 09:11:24 UTC) #25
haraken
platform/ LGTM
4 years, 6 months ago (2016-06-09 11:15:50 UTC) #27
yhirano
Sorry for after-l-g-t-m comments, I've just noticed I don't know if we should trace CrossThread[Weak]Persistent. ...
4 years, 6 months ago (2016-06-09 11:36:20 UTC) #28
nhiroki
On 2016/06/09 11:36:20, yhirano wrote: > Sorry for after-l-g-t-m comments, I've just noticed I don't ...
4 years, 6 months ago (2016-06-09 13:23:21 UTC) #29
nhiroki
Updated. https://codereview.chromium.org/2025783002/diff/300001/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp File third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp (right): https://codereview.chromium.org/2025783002/diff/300001/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp#newcode375 third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp:375: visitor->trace(m_bridge); On 2016/06/09 11:36:20, yhirano wrote: > Peer::m_bridge ...
4 years, 6 months ago (2016-06-09 13:23:51 UTC) #30
haraken
On 2016/06/09 13:23:21, nhiroki wrote: > On 2016/06/09 11:36:20, yhirano wrote: > > Sorry for ...
4 years, 6 months ago (2016-06-09 13:35:06 UTC) #31
nhiroki
On 2016/06/09 13:35:06, haraken wrote: > On 2016/06/09 13:23:21, nhiroki wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 14:14:24 UTC) #32
haraken
> Thank you for the information. On the patchset 8, CrossThread(Weak)Persistents > are traced but ...
4 years, 6 months ago (2016-06-09 14:15:07 UTC) #34
sof
On 2016/06/09 14:15:07, haraken wrote: > > Thank you for the information. On the patchset ...
4 years, 6 months ago (2016-06-09 14:24:30 UTC) #35
nhiroki
On 2016/06/09 14:24:30, sof wrote: > On 2016/06/09 14:15:07, haraken wrote: > > > Thank ...
4 years, 6 months ago (2016-06-09 15:00:35 UTC) #36
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2025783002/320001
4 years, 6 months ago (2016-06-09 15:02:13 UTC) #39
commit-bot: I haz the power
Committed patchset #9 (id:320001)
4 years, 6 months ago (2016-06-09 15:17:36 UTC) #41
commit-bot: I haz the power
CQ bit was unchecked
4 years, 6 months ago (2016-06-09 15:17:40 UTC) #42
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/ff24de0d44123ca7ae9b9511268fdd926356a36f Cr-Commit-Position: refs/heads/master@{#398886}
4 years, 6 months ago (2016-06-09 15:19:21 UTC) #44
sof
On 2016/06/09 15:00:35, nhiroki wrote: > On 2016/06/09 14:24:30, sof wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 15:19:58 UTC) #45
sof
On 2016/06/09 15:19:58, sof wrote: > On 2016/06/09 15:00:35, nhiroki wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 15:31:32 UTC) #46
yhirano
On 2016/06/09 15:31:32, sof wrote: > On 2016/06/09 15:19:58, sof wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 16:01:34 UTC) #47
sof
On 2016/06/09 16:01:34, yhirano wrote: > On 2016/06/09 15:31:32, sof wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 18:00:10 UTC) #48
nhiroki
On 2016/06/09 18:00:10, sof wrote: > On 2016/06/09 16:01:34, yhirano wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-09 23:04:41 UTC) #51
haraken
On 2016/06/09 23:04:41, nhiroki wrote: > On 2016/06/09 18:00:10, sof wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-10 00:30:53 UTC) #52
haraken
https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h File third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h (right): https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h#newcode28 third_party/WebKit/Source/core/workers/WorkerThreadLifecycleObserver.h:28: // and contextDestroyed() is never notified. This looks like ...
4 years, 6 months ago (2016-06-10 00:45:37 UTC) #53
yhirano
https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h File third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h (right): https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h#newcode121 third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h:121: CrossThreadWeakPersistent<Bridge> m_bridge; On 2016/06/10 00:45:36, haraken wrote: > > ...
4 years, 6 months ago (2016-06-10 01:54:05 UTC) #54
kinuko
some nits https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/core/workers/WorkerThread.h File third_party/WebKit/Source/core/workers/WorkerThread.h (right): https://codereview.chromium.org/2025783002/diff/320001/third_party/WebKit/Source/core/workers/WorkerThread.h#newcode61 third_party/WebKit/Source/core/workers/WorkerThread.h:61: class CORE_EXPORT WorkerThreadContext final : public GarbageCollectedFinalized<WorkerThreadContext>, ...
4 years, 6 months ago (2016-06-10 02:05:29 UTC) #56
nhiroki
Thanks for your comments! I'll make a follow-up CL to change the semantics etc soon.
4 years, 6 months ago (2016-06-10 02:16:14 UTC) #57
sof
On 2016/06/10 00:30:53, haraken wrote: > On 2016/06/09 23:04:41, nhiroki wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-10 05:11:06 UTC) #58
haraken
On 2016/06/10 05:11:06, sof wrote: > On 2016/06/10 00:30:53, haraken wrote: > > On 2016/06/09 ...
4 years, 6 months ago (2016-06-10 05:24:05 UTC) #59
sof
4 years, 6 months ago (2016-06-10 05:57:17 UTC) #60
Message was sent while issue was closed.
On 2016/06/10 05:24:05, haraken wrote:
> On 2016/06/10 05:11:06, sof wrote:
> > On 2016/06/10 00:30:53, haraken wrote:
> > > On 2016/06/09 23:04:41, nhiroki wrote:
....
> >
>
https://docs.google.com/document/d/14MzxMuUV9e5ZgxbZL3-jCMKa3S-UJGsbYSmRodLh9...
> > > > 
> > > > In this CL, Bridge is owned by the worker thread and Peer is owned by
the
> > main
> > > > thread, so I think they need to reference each other via
> > > > CrossThread(Weak)Persistent.
> > > 
> > > Yeah, let's add the description to BlinkGCAPIReferences.md.
> > > 
> > > My only concern of using CrossThreadPersistent for cross-origin pointers
is
> > that
> > > it may introduce new leaks, but we already have ASSERT(persistentCount ==
0)
> > at
> > > the end of a thread-termination GC, which would help catch the leaks.
> > 
> > CrossThreadPersistent<>s aren't covered by thread-termination GCs & that
> assert,
> > i think.
> 
> Ideally I think we should cover them, but I'm not sure how many callsites we
> need to fix to enable the assert...

Co-opting a global registry of persistent pointers & the abstraction
CrossThreadPersistent<>, to represent a pointer between heap objects on heaps N
& M, is worrisome.

Powered by Google App Engine
This is Rietveld 408576698