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

Issue 2951903003: Hold global GC heap lock while making audio thread access. (Closed)

Created:
3 years, 6 months ago by sof
Modified:
3 years, 6 months ago
CC:
Raymond Toy, Mads Ager (chromium), blink-reviews, chromium-reviews, hongchan, kinuko+watch, kouhei+heap_chromium.org, oilpan-reviews
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Hold global GC heap lock while making audio thread access. For auxillary threads that rarely need to gain access to another thread's GC heap, we have to ensure that this happens while the heap-owning thread isn't concurrently GCing the heap. Otherwise there is the possibility that heap objects might be relocated or mutated while the auxillary thread tries to access. A CrossThreadPersistent<T> (CTP) ensures reference liveness across threads, but isn't sufficient to handle the wanted exclusive access after a non-attached thread has deref'ed the persistent. So, for this to happen, keep the global CTP lock while accessing a heap object during offline audio rendering -- it specifically accessing heap objects while a GC runs. As all GCs hold the lock on the global CTP region while they run, this ensures exclusion. It is clearly desirable to have all heap access be under the control of the heap-owning thread, and threaded code should try hard to avoid accessing another thread's heap objects. The CTP global lock is the mechanism to use when that isn't practically feasible -- feel free to add a "TODO(foo): avoid using" next to any instances that you end up introducing. As regards audio thread cross-thread usage, the code needs auditing to check if there are other places where setting up this CTP lock is required. R=haraken,rtoy,hongchan BUG=732511 Review-Url: https://codereview.chromium.org/2951903003 Cr-Commit-Position: refs/heads/master@{#481809} Committed: https://chromium.googlesource.com/chromium/src/+/2ad39770967ebd93314070776ffe92d3eaeb8a6b

Patch Set 1 #

Patch Set 2 : repurpose CrossThreadPersistentRegion::LockScope #

Patch Set 3 : comment capitalization #

Patch Set 4 : take GC lock earlier #

Patch Set 5 : move GC locking outwards #

Patch Set 6 : go back to GCLockScope #

Patch Set 7 : revert CTP::LockScope changes #

Patch Set 8 : verify LockScope timeouts #

Patch Set 9 : revert ps#8 changes #

Patch Set 10 : final version #

Patch Set 11 : consistent lock scope wrt heap object in question #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -11 lines) Patch
M third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +18 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/platform/heap/PersistentNode.h View 1 2 7 8 9 2 chunks +19 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/platform/heap/ThreadState.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -3 lines 0 comments Download

Messages

Total messages: 52 (38 generated)
sof
please take a look.
3 years, 6 months ago (2017-06-21 07:51:06 UTC) #4
haraken
> threaded code should try hard to avoid accessing the a thread's heap from another. ...
3 years, 6 months ago (2017-06-21 11:00:40 UTC) #5
sof
On 2017/06/21 11:00:40, haraken wrote: > > threaded code should try hard to avoid accessing ...
3 years, 6 months ago (2017-06-21 11:11:12 UTC) #6
haraken
This is going to be weird anyway, so I don't have any strong opinion but... ...
3 years, 6 months ago (2017-06-21 11:16:50 UTC) #7
sof
On 2017/06/21 11:16:50, haraken wrote: > This is going to be weird anyway, so I ...
3 years, 6 months ago (2017-06-21 11:22:57 UTC) #8
sof
On 2017/06/21 11:22:57, sof wrote: > On 2017/06/21 11:16:50, haraken wrote: > > This is ...
3 years, 6 months ago (2017-06-21 12:54:50 UTC) #12
haraken
LGTM
3 years, 6 months ago (2017-06-21 12:58:14 UTC) #15
Raymond Toy
lgtm
3 years, 6 months ago (2017-06-21 14:40:54 UTC) #17
hongchan
This might affect the timing of suspend/resume call when it happens, but we can't avoid ...
3 years, 6 months ago (2017-06-21 14:55:35 UTC) #20
sof
On 2017/06/21 14:55:35, hongchan (OOO Jun 19-22) wrote: > This might affect the timing of ...
3 years, 6 months ago (2017-06-22 05:58:36 UTC) #41
sof
landing; will followup, should there be more feedback.
3 years, 6 months ago (2017-06-23 05:25:32 UTC) #45
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/2951903003/200001
3 years, 6 months ago (2017-06-23 05:25:53 UTC) #48
commit-bot: I haz the power
Committed patchset #11 (id:200001) as https://chromium.googlesource.com/chromium/src/+/2ad39770967ebd93314070776ffe92d3eaeb8a6b
3 years, 6 months ago (2017-06-23 05:29:07 UTC) #51
xidachen
3 years, 6 months ago (2017-06-23 18:20:28 UTC) #52
Message was sent while issue was closed.
On 2017/06/23 05:29:07, commit-bot: I haz the power wrote:
> Committed patchset #11 (id:200001) as
>
https://chromium.googlesource.com/chromium/src/+/2ad39770967ebd93314070776ffe...

Hi,

By looking at the flakiness dashboard here:
https://test-results.appspot.com/dashboards/flakiness_dashboard.html#testType...
This CL seems to cause the webaudio/internals/audiosource-premature-gc.html to
timeout.

Powered by Google App Engine
This is Rietveld 408576698