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}
Showing
Please register or sign in to comment