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

Issue 2837303003: Fix the crash due to AudioRendererImpl::audio_clock_ being null (Closed)

Created:
3 years, 8 months ago by servolk
Modified:
3 years, 7 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix the crash due to AudioRendererImpl::audio_clock_ being null Previously AudioRendererImpl::Initialize used to be called only once before the renderer was started, so we didn't need a lock in there. But now AudioRenderer::Initialize might get called again when switching audio tracks, so we need to have a lock in there to be safe. The lock will prevent audio_clock_ from being accessed from CurrentMediaTime while the audio renderer is being reinitialized. BUG=715191

Patch Set 1 #

Patch Set 2 : Release the ARI lock while stopping the sink #

Patch Set 3 : Safer fix + rebase #

Total comments: 3

Patch Set 4 : Don't reset audio_clock_ explicitly + remove the DCHECK #

Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -7 lines) Patch
M media/renderers/audio_renderer_impl.cc View 1 2 3 1 chunk +7 lines, -7 lines 0 comments Download

Messages

Total messages: 31 (19 generated)
servolk
3 years, 7 months ago (2017-05-17 00:11:24 UTC) #14
DaleCurtis
Seems wrong? I thought we chatted about this and decided that the lock was unnecessary ...
3 years, 7 months ago (2017-05-17 00:14:21 UTC) #16
DaleCurtis
https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc File media/renderers/audio_renderer_impl.cc (right): https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc#newcode355 media/renderers/audio_renderer_impl.cc:355: audio_clock_.reset(); Instead just delete the CHECK below seems like ...
3 years, 7 months ago (2017-05-17 00:15:52 UTC) #17
DaleCurtis
+chcunningham who added that check.
3 years, 7 months ago (2017-05-17 00:16:06 UTC) #19
servolk
On 2017/05/17 00:14:21, DaleCurtis_OOO_May_5_To_May23 wrote: > Seems wrong? I thought we chatted about this and ...
3 years, 7 months ago (2017-05-17 00:19:15 UTC) #20
servolk
https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc File media/renderers/audio_renderer_impl.cc (right): https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc#newcode355 media/renderers/audio_renderer_impl.cc:355: audio_clock_.reset(); On 2017/05/17 00:15:52, DaleCurtis_OOO_May_5_To_May23 wrote: > Instead just ...
3 years, 7 months ago (2017-05-17 00:23:31 UTC) #21
servolk
https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc File media/renderers/audio_renderer_impl.cc (right): https://codereview.chromium.org/2837303003/diff/40001/media/renderers/audio_renderer_impl.cc#newcode355 media/renderers/audio_renderer_impl.cc:355: audio_clock_.reset(); On 2017/05/17 00:23:31, servolk wrote: > On 2017/05/17 ...
3 years, 7 months ago (2017-05-17 00:27:12 UTC) #23
DaleCurtis
Sorry, there can not be a lock here. If one exists we're doing something wrong. ...
3 years, 7 months ago (2017-05-17 00:35:43 UTC) #25
servolk
On 2017/05/17 00:35:43, DaleCurtis_OOO_May_5_To_May23 wrote: > Sorry, there can not be a lock here. If ...
3 years, 7 months ago (2017-05-17 00:45:14 UTC) #26
DaleCurtis
On 2017/05/17 at 00:45:14, servolk wrote: > On 2017/05/17 00:35:43, DaleCurtis_OOO_May_5_To_May23 wrote: > > Sorry, ...
3 years, 7 months ago (2017-05-17 00:51:52 UTC) #27
servolk
On 2017/05/17 00:51:52, DaleCurtis_OOO_May_5_To_May23 wrote: > On 2017/05/17 at 00:45:14, servolk wrote: > > On ...
3 years, 7 months ago (2017-05-17 01:23:37 UTC) #28
servolk
3 years, 7 months ago (2017-05-17 21:53:50 UTC) #31
On 2017/05/17 01:23:37, servolk wrote:
> On 2017/05/17 00:51:52, DaleCurtis_OOO_May_5_To_May23 wrote:
> > On 2017/05/17 at 00:45:14, servolk wrote:
> > > On 2017/05/17 00:35:43, DaleCurtis_OOO_May_5_To_May23 wrote:
> > > > Sorry, there can not be a lock here. If one exists we're doing something
> > wrong.
> > > > There should be no access into ARI while the track change is occurring,
> > > > RendererImpl needs to hold all calls until the track change completes.
> > > 
> > > TBH it's not clear to me - why is having a lock here unacceptable? What
> could
> > break?
> > 
> > This lock primarily guards Render() and the audio data structures. No calls
> > should be coming into ARI while we're changing tracks. The lock
unnecessarily
> > complicates the design by extending the lock for unintended purposes. It's
> also
> > papering over only one of the issues here -- see my next comment.
> > 
> > > 
> > > If we want to hold on RendererImpl level, then we might run into other
> > problems. ARI::CurrentMediaTime is called from RendererImpl::GetMediaTime
> (since
> > time_source_ is audio renderer), but according to the comment at
> >
>
https://cs.chromium.org/chromium/src/media/renderers/renderer_impl.cc?rcl=efe...
> > the RendererImpl::GetMediaTime gets called on a different thread, so we
> probably
> > can't safely access the RendererImpl::restarting_audio_ flag from there, or
> can
> > we?
> > 
> > As soon as track switches are started, basically no calls should be allowed
> into
> > the ARI (or VRI for that matter) until the track change completes. Time
should
> > freeze and renderer impl should return a cached value while track changes
are
> in
> > progress. We may need a lock there to coordinate this, but putting the lock
in
> > ARI initialize is not correct.
> 
> Well, I guess we could do something like this:
> https://codereview.chromium.org/2890603004
> It does fix the crash in the media/avtrack/track-switching.html layout test,
but
> we'll probably need to add a lock for the RI::restarting_audio_ flag to be
> really safe? I'll test that CL some more tomorrow.

Ok, the https://codereview.chromium.org/2890603004 seems to work well enough,
and I realized that we could just use an std::atomic<bool> for the
RI::restarting_audio_ flag. So I'll abandon this CL and will land
https://codereview.chromium.org/2890603004 instead, PTAL.

Powered by Google App Engine
This is Rietveld 408576698