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

Issue 2698813007: Fix teardown of stale AudioStreamMonitor poll callbacks. (Closed)

Created:
3 years, 10 months ago by DaleCurtis
Modified:
3 years, 10 months ago
Reviewers:
Charlie Reis, Max Morin
CC:
chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, feature-media-reviews_chromium.org, jam, miu+watch_chromium.org, nasko+codewatch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix teardown of stale AudioStreamMonitor poll callbacks. It's possible for the RenderProcessHost and WebContents (and thus AudioStreamMonitor) to survive the death of the render process and subsequently be reused. During this period StartStopMonitoringHelper() will be unable to lookup the WebContents using the now-dead |render_frame_id|. We must thus have a secondary mechanism for clearing stale callbacks. This change introduces AudioStreamMonitor:RenderProcessGone() which is called by the WebContents whenever WCO::RenderProcessGone() is. This allows the audio stream monitor to clear stale callbacks that the AudioOutputDelegateImpl will no longer be able to route to it. Subsequently this also fixes a bug on Android (and anywhere else power monitoring is disabled), where process termination would not correctly clear the audible state for a process. On all platforms this fixes a minor leak of AudioOutputController objects, since they are bound by ref-ptr into the callback map containing stale entries. I say minor since they would immediately be overwritten if the process is reusued or tossed completely when the WebContents object goes away. BUG=692857 TEST=new unittest, manual test: 1. load http://mounirlamouri.github.io/sandbox/autoplay/test.html 2. kill process from task manager. 3. click the reload button == boom (boom no longer after patch!). Review-Url: https://codereview.chromium.org/2698813007 Cr-Commit-Position: refs/heads/master@{#451664} Committed: https://chromium.googlesource.com/chromium/src/+/3d1e1301ee8f7c1cab24e2d161218336ea0e7b7c

Patch Set 1 #

Total comments: 6

Patch Set 2 : Relocate RenderProcessGone() call. #

Patch Set 3 : Always store callbacks, fix tests. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+119 lines, -41 lines) Patch
M content/browser/media/audio_stream_monitor.h View 1 2 3 chunks +6 lines, -6 lines 0 comments Download
M content/browser/media/audio_stream_monitor.cc View 1 2 6 chunks +49 lines, -29 lines 0 comments Download
M content/browser/media/audio_stream_monitor_unittest.cc View 1 2 6 chunks +62 lines, -6 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (11 generated)
DaleCurtis
Found the bug :)
3 years, 10 months ago (2017-02-17 02:06:36 UTC) #2
Max Morin
Cool! Nice job figuring this out, I wish there was clear documentation on the relationship ...
3 years, 10 months ago (2017-02-17 08:14:28 UTC) #6
Max Morin
https://codereview.chromium.org/2698813007/diff/1/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/2698813007/diff/1/content/browser/web_contents/web_contents_impl.cc#newcode4401 content/browser/web_contents/web_contents_impl.cc:4401: audio_stream_monitor_.RenderProcessGone(rvh->GetProcess()->GetID()); Actually, this code confuses me. Shouldn't audio_stream_monitor_ be ...
3 years, 10 months ago (2017-02-17 16:39:53 UTC) #7
DaleCurtis
https://codereview.chromium.org/2698813007/diff/1/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/2698813007/diff/1/content/browser/web_contents/web_contents_impl.cc#newcode4401 content/browser/web_contents/web_contents_impl.cc:4401: audio_stream_monitor_.RenderProcessGone(rvh->GetProcess()->GetID()); On 2017/02/17 at 16:39:53, Max Morin wrote: > ...
3 years, 10 months ago (2017-02-17 17:23:03 UTC) #8
Charlie Reis
Nice find! LGTM. https://codereview.chromium.org/2698813007/diff/1/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/2698813007/diff/1/content/browser/media/audio_stream_monitor.cc#newcode26 content/browser/media/audio_stream_monitor.cc:26: // at time of call; e.g., ...
3 years, 10 months ago (2017-02-17 21:27:55 UTC) #9
DaleCurtis
Thanks for review! https://codereview.chromium.org/2698813007/diff/1/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/2698813007/diff/1/content/browser/media/audio_stream_monitor.cc#newcode26 content/browser/media/audio_stream_monitor.cc:26: // at time of call; e.g., ...
3 years, 10 months ago (2017-02-17 22:03:59 UTC) #11
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/2698813007/20001
3 years, 10 months ago (2017-02-17 22:05:45 UTC) #13
commit-bot: I haz the power
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_swarming_rel/builds/121910)
3 years, 10 months ago (2017-02-17 23:39:44 UTC) #15
DaleCurtis
Turns out I hadn't really fixed the Android issue, maxmorin@ PTAL. We now always store ...
3 years, 10 months ago (2017-02-18 01:03:30 UTC) #16
Max Morin
On 2017/02/18 01:03:30, DaleCurtis wrote: > Turns out I hadn't really fixed the Android issue, ...
3 years, 10 months ago (2017-02-20 07:45:07 UTC) #17
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/2698813007/40001
3 years, 10 months ago (2017-02-20 21:24:49 UTC) #20
commit-bot: I haz the power
3 years, 10 months ago (2017-02-20 22:34:01 UTC) #23
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/3d1e1301ee8f7c1cab24e2d16121...

Powered by Google App Engine
This is Rietveld 408576698