|
|
Created:
4 years, 6 months ago by o1ka Modified:
4 years, 6 months ago Reviewers:
DaleCurtis CC:
chromium-reviews, feature-media-reviews_chromium.org, Henrik Grunell, tommi (sloooow) - chröme, vanellope-cl_google.com Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionFixing deadlock by removing unnesessary lock in AudioRendererMixer
Deadlock is like this:
On main or media thread:
ARMM::GetOutputDeviceInfo [takes |lock_|]
-> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only
On IO thread:
AOD::CreateStreamOnIOThread/OnStateChanged*
-> ARMM::OnRenderError [takes |lock_|],
so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled.
*AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError()
That lock in ARMM::GetOutputDeviceInfo is never needed, after all
BUG=615589
Committed: https://crrev.com/c017b5d078463e7265b5bef1d34a25a57859293c
Cr-Commit-Position: refs/heads/master@{#400735}
Patch Set 1 #
Messages
Total messages: 16 (5 generated)
Description was changed from ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 ========== to ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 ==========
olka@chromium.org changed reviewers: + dalecurtis@chromium.org
Dale, PTAL.
lgtm
Nice find!
(Sorry, should have caught this during review, we should almost never call into sinks under lock)
The CQ bit was checked by olka@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2085603002/1
On 2016/06/20 17:16:17, DaleCurtis wrote: > (Sorry, should have caught this during review, we should almost never call into > sinks under lock) Well, I'm kind of an author of this deadlock, so it's my fault. Actually, we do call Start/Play under lock pretty often (and here as well), but ARM is the only case where the lock is held in OnRenderError() => acquired on IO thread, so it slipped through.
On 2016/06/20 at 17:22:26, olka wrote: > On 2016/06/20 17:16:17, DaleCurtis wrote: > > (Sorry, should have caught this during review, we should almost never call into > > sinks under lock) > > Well, I'm kind of an author of this deadlock, so it's my fault. > > Actually, we do call Start/Play under lock pretty often (and here as well), but ARM is the only case where the lock is held in OnRenderError() => acquired on IO thread, so it slipped through. We don't call Start/Play under lock in this class, nor any of the other classes under media that I'm aware of -- for exactly this reason, we can hit deadlock.
On 2016/06/20 17:40:28, DaleCurtis wrote: > On 2016/06/20 at 17:22:26, olka wrote: > > On 2016/06/20 17:16:17, DaleCurtis wrote: > > > (Sorry, should have caught this during review, we should almost never call > into > > > sinks under lock) > > > > Well, I'm kind of an author of this deadlock, so it's my fault. > > > > Actually, we do call Start/Play under lock pretty often (and here as well), > but ARM is the only case where the lock is held in OnRenderError() => acquired > on IO thread, so it slipped through. > > We don't call Start/Play under lock in this class, nor any of the other classes > under media that I'm aware of -- for exactly this reason, we can hit deadlock. Here, for example https://cs.chromium.org/chromium/src/media/base/audio_renderer_mixer.cc?q=Aud.... We don't call Stop() under lock, because it deadlocks with Render() call if it holds the same lock. Start/Play are asynchronous, so they should be safe.
On 2016/06/20 at 17:46:10, olka wrote: > On 2016/06/20 17:40:28, DaleCurtis wrote: > > On 2016/06/20 at 17:22:26, olka wrote: > > > On 2016/06/20 17:16:17, DaleCurtis wrote: > > > > (Sorry, should have caught this during review, we should almost never call > > into > > > > sinks under lock) > > > > > > Well, I'm kind of an author of this deadlock, so it's my fault. > > > > > > Actually, we do call Start/Play under lock pretty often (and here as well), > > but ARM is the only case where the lock is held in OnRenderError() => acquired > > on IO thread, so it slipped through. > > > > We don't call Start/Play under lock in this class, nor any of the other classes > > under media that I'm aware of -- for exactly this reason, we can hit deadlock. > > Here, for example https://cs.chromium.org/chromium/src/media/base/audio_renderer_mixer.cc?q=Aud.... > We don't call Stop() under lock, because it deadlocks with Render() call if it holds the same lock. Start/Play are asynchronous, so they should be safe. Ah, yes you're correct. I think previously we have assumed even Play/Pause aren't safe, but they are. Will send you a patch for that.
Message was sent while issue was closed.
Description was changed from ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 ========== to ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 ==========
Message was sent while issue was closed.
Committed patchset #1 (id:1)
Message was sent while issue was closed.
Description was changed from ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 ========== to ========== Fixing deadlock by removing unnesessary lock in AudioRendererMixer Deadlock is like this: On main or media thread: ARMM::GetOutputDeviceInfo [takes |lock_|] -> AOD::GetOutputDeviceInfo -> waits for device authorization, which can be signalled on IO thread only On IO thread: AOD::CreateStreamOnIOThread/OnStateChanged* -> ARMM::OnRenderError [takes |lock_|], so OnDeviceAuthorized/OnIPCClosed will never be called and device authorization will never be signalled. *AOD::OnDeviceAuthorized itself does not deadlock it always signals event before calling OnRenderError() That lock in ARMM::GetOutputDeviceInfo is never needed, after all BUG=615589 Committed: https://crrev.com/c017b5d078463e7265b5bef1d34a25a57859293c Cr-Commit-Position: refs/heads/master@{#400735} ==========
Message was sent while issue was closed.
Patchset 1 (id:??) landed as https://crrev.com/c017b5d078463e7265b5bef1d34a25a57859293c Cr-Commit-Position: refs/heads/master@{#400735} |