|
|
Chromium Code Reviews|
Created:
4 years, 6 months ago by qinmin Modified:
4 years, 5 months ago CC:
chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, feature-media-reviews_chromium.org, jam, mcasas+watch+vc_chromium.org, miu+watch_chromium.org, nasko+codewatch_chromium.org, phoglund+watch_chromium.org, posciak+watch_chromium.org, tnakamura+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionIntiialize AudioManager and related class lazily
AudioManager is created when browser process is created.
However, for background download resumption, we don't need AudioManager
for download to resume.
Creating the AudioManager takes about 10KB of memory.
This is only needed when the first renderer is created.
This CL delays AudioManager creation until it is first referenced.
This also involves some other classes that depends on AudioManager.
BUG=620479
Committed: https://crrev.com/c8569a7cd8c3cb6f9cd22467e084860721ceadd7
Cr-Commit-Position: refs/heads/master@{#404014}
Patch Set 1 #
Total comments: 6
Patch Set 2 : apply the lazy initialization only to Android #
Total comments: 1
Patch Set 3 : move changes into AudioManagerAndroid #Patch Set 4 : defer StartHangMonitor() on all platforms #
Total comments: 2
Patch Set 5 : check if StartHangTimer() is called earlier #
Total comments: 2
Patch Set 6 : fix test and lazy init jobj #Patch Set 7 : fix MediaSessionTest #
Messages
Total messages: 77 (35 generated)
qinmin@chromium.org changed reviewers: + sievers@chromium.org
PTAL
The CQ bit was checked by qinmin@chromium.org
The CQ bit was unchecked by qinmin@chromium.org
The CQ bit was checked by qinmin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2077983003/1
looks like a good idea. did you run it by some desktop folks though to make sure there are no hidden assumptions somehow about this being initialized early? > Creating the AudioManager is quite costly, nit: could you update it to say 'costly in terms of memory'? https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... File content/browser/browser_main_loop.cc (right): https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1495: media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); nit: or just write newMediaStreamManager(GetAudioManager()); https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1505: audio_manager_.get(), media_stream_manager_.get())); nit: same here
dalecurtis@chromium.org changed reviewers: + dalecurtis@chromium.org
This is not true, the AudioManager has several callers in the browser process.
Can you elaborate on the cost here? On most platforms it does nothing except start a thread and post a task.
dalecurtis@chromium.org changed reviewers: + tommi@chromium.org
+tommi
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
On 2016/06/18 00:21:14, DaleCurtis wrote: > This is not true, the AudioManager has several callers in the browser process. Yes,there is callers in browser process. But we don't need AudioManager if there is no RenderProcessHost. For download resumption, we only need to create the browser process, and there is no renderer process. So we can delay AudioManager creation util the first renderer is created.
On 2016/06/18 00:21:37, DaleCurtis wrote: > Can you elaborate on the cost here? On most platforms it does nothing except > start a thread and post a task. When AudioThread is created, 2 tasks are posted: RecordAudioThreadStatus and UpdateLastAudioThreadTimeTick. Both will allocate some memory and totally they contributed about 10KB to overall memory usage.
Description was changed from ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager is quite costly, it is only needed when renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 ========== to ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager takes about 10KB of memory. This is only needed when the first renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 ==========
are the bot failures related? https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... File content/browser/browser_main_loop.cc (right): https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1450: media::AudioManager* BrowserMainLoop::GetAudioManager() { make sure this always runs on the same thread
On 2016/06/18 at 04:04:24, qinmin wrote: > On 2016/06/18 00:21:14, DaleCurtis wrote: > > This is not true, the AudioManager has several callers in the browser process. > > Yes,there is callers in browser process. But we don't need AudioManager if there is no RenderProcessHost. > For download resumption, we only need to create the browser process, and there is no renderer process. So we can delay AudioManager creation util the first renderer is created. No, I mean there are callers into this code before there is a renderer -- at least on ChromeOS, which is likely why some of those tests are failing. The AM code is used to play startup sounds during boot. I believe there are (or were) callers on other platforms which made use of the AM code as well (copresence maybe?).
On 2016/06/20 at 16:22:35, DaleCurtis wrote: > On 2016/06/18 at 04:04:24, qinmin wrote: > > On 2016/06/18 00:21:14, DaleCurtis wrote: > > > This is not true, the AudioManager has several callers in the browser process. > > > > Yes,there is callers in browser process. But we don't need AudioManager if there is no RenderProcessHost. > > For download resumption, we only need to create the browser process, and there is no renderer process. So we can delay AudioManager creation util the first renderer is created. > > No, I mean there are callers into this code before there is a renderer -- at least on ChromeOS, which is likely why some of those tests are failing. The AM code is used to play startup sounds during boot. I believe there are (or were) callers on other platforms which made use of the AM code as well (copresence maybe?). But to be clear, if you can solve these concerns, doing this is fine with me.
Patchset #2 (id:20001) has been deleted
Chatted with sievers@, and agree to limit the lazy initialization to Android only. https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... File content/browser/browser_main_loop.cc (right): https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1450: media::AudioManager* BrowserMainLoop::GetAudioManager() { On 2016/06/18 13:49:03, tommi-chrömium wrote: > make sure this always runs on the same thread Done. https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1495: media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); On 2016/06/18 00:17:20, sievers wrote: > nit: or just write newMediaStreamManager(GetAudioManager()); no longer needed with the new patch https://codereview.chromium.org/2077983003/diff/1/content/browser/browser_mai... content/browser/browser_main_loop.cc:1505: audio_manager_.get(), media_stream_manager_.get())); On 2016/06/18 00:17:20, sievers wrote: > nit: same here no longer needed with the new patch
lgtm if Dale is happy too https://codereview.chromium.org/2077983003/diff/40001/content/browser/browser... File content/browser/browser_main_loop.cc (right): https://codereview.chromium.org/2077983003/diff/40001/content/browser/browser... content/browser/browser_main_loop.cc:1233: TRACE_EVENT0("startup", "BrowserThreadsStarted::InitMediaComponents"); nit: maybe move the trace event into the function where we actually init?
I'd prefer not to add more one-offs just for Android. Sorry to ask a probably-desktop centric question, but is this really worth it for 10kb? The risk is that we're adding yet another feature that works slightly differently when run on different platforms. By deferring this you're deferring an entire chain of initialization. If we're going to do this, I'd prefer we did it on all platforms where we have more test coverage for what can go wrong. I.e., have you looked into the failures that have occurred so far? Are they all ChromeOS related or is there a larger issue hiding?
On 2016/06/21 00:16:32, DaleCurtis wrote: > I'd prefer not to add more one-offs just for Android. Good point. If you want different behavior, why not handle that in audio_manager_android.cc (and lazily init there)?
On 2016/06/21 00:16:32, DaleCurtis wrote: > I'd prefer not to add more one-offs just for Android. Sorry to ask a > probably-desktop centric question, but is this really worth it for 10kb? The > risk is that we're adding yet another feature that works slightly differently > when run on different platforms. > > By deferring this you're deferring an entire chain of initialization. If we're > going to do this, I'd prefer we did it on all platforms where we have more test > coverage for what can go wrong. I.e., have you looked into the failures that > have occurred so far? Are they all ChromeOS related or is there a larger issue > hiding? For a regular browser session, 10KB is not really worth saving. But for background download resumption(no GPU, no Renderer), 10 KB is something we should not skip. Especially the bigger the memory footprint, the higher the chance to get killed by OS. Currently Background resumption takes about 13M private dirty currently, and we really want to bring it down to 10MB. There are not a lot of big items we can shrink immediately to get to the target, so saving small pieces here and there would helps. The failure on chromeOS is caused by that ChromeOS needs AudioManager to create a SoundsManager object during startup. If I initialize AudioManager before SoundsManager is created, the all the tests will pass. However, chromeOS is under chrome/browser, and browser_main_loop is in content/browser. So I have to create a static interface in content/public, and let chromeOS call that function to initialize the AudioManager. Not sure if this is the right way to do
On 2016/06/21 00:19:17, sievers wrote: > On 2016/06/21 00:16:32, DaleCurtis wrote: > > I'd prefer not to add more one-offs just for Android. > > Good point. If you want different behavior, why not handle that in > audio_manager_android.cc (and lazily init there)? The extra memory is introduced by AudioManager::StartHangMonitor(). If we can lazily call that function, then it would also be ok. @dalecurtis, the hang timer is disabled on mac. Do we need it on Android? Since Chrome interact with openSL ES on the audio thread, i guess that it is still needed. But can we lazily start monitoring until the first renderer is created?
On 2016/06/21 at 17:27:49, qinmin wrote: > On 2016/06/21 00:19:17, sievers wrote: > > On 2016/06/21 00:16:32, DaleCurtis wrote: > > > I'd prefer not to add more one-offs just for Android. > > > > Good point. If you want different behavior, why not handle that in > > audio_manager_android.cc (and lazily init there)? > > The extra memory is introduced by AudioManager::StartHangMonitor(). If we can lazily call that function, then it would also be ok. > @dalecurtis, the hang timer is disabled on mac. Do we need it on Android? Since Chrome interact with openSL ES on the audio thread, i guess that it is still needed. > But can we lazily start monitoring until the first renderer is created? If it's just the hang monitor can you disable that only for background sessions? That is only reporting a UMA right now and it's sitting at 100% okay right now.
On 2016/06/21 19:27:10, DaleCurtis wrote: > On 2016/06/21 at 17:27:49, qinmin wrote: > > On 2016/06/21 00:19:17, sievers wrote: > > > On 2016/06/21 00:16:32, DaleCurtis wrote: > > > > I'd prefer not to add more one-offs just for Android. > > > > > > Good point. If you want different behavior, why not handle that in > > > audio_manager_android.cc (and lazily init there)? > > > > The extra memory is introduced by AudioManager::StartHangMonitor(). If we can > lazily call that function, then it would also be ok. > > @dalecurtis, the hang timer is disabled on mac. Do we need it on Android? > Since Chrome interact with openSL ES on the audio thread, i guess that it is > still needed. > > But can we lazily start monitoring until the first renderer is created? > > If it's just the hang monitor can you disable that only for background sessions? > That is only reporting a UMA right now and it's sitting at 100% okay right now. PTAL again. Changed the implementation to delay calling of AudioManager::StartHangMonitor(). The new patch also delays creation of the java object, and moving the change into AudioManagerAndroid.
Hmm, why not just always defer StartHangMonitor until a render process is attached? I also think if you want to defer JNI creation you can just have an internal method in AudioManagerAndroid which handles that upon first call into any JNI using methods.
On 2016/06/21 at 21:27:44, DaleCurtis wrote: > Hmm, why not just always defer StartHangMonitor until a render process is attached? I also think if you want to defer JNI creation you can just have an internal method in AudioManagerAndroid which handles that upon first call into any JNI using methods. Note: You probably want to take some care about the AudioManagerAndroid destructor too. It will always try to call into AudioManager::close() even if initialize never started.
On 2016/06/21 21:28:49, DaleCurtis wrote: > On 2016/06/21 at 21:27:44, DaleCurtis wrote: > > Hmm, why not just always defer StartHangMonitor until a render process is > attached? I also think if you want to defer JNI creation you can just have an > internal method in AudioManagerAndroid which handles that upon first call into > any JNI using methods. > Ok, Deferred StartHangMonitor on all platforms. For JNI creation, we cannot defer it as the JNI inti() call will initialize some intent broadcast receivers. So defering it will disable Chrome from listening to those intents until audio is played. > Note: You probably want to take some care about the AudioManagerAndroid > destructor too. It will always try to call into AudioManager::close() even if > initialize never started. Done.
lgtm though InitializeIfNeeded() is a bit misleading.
https://codereview.chromium.org/2077983003/diff/80001/content/browser/rendere... File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2077983003/diff/80001/content/browser/rendere... content/browser/renderer_host/render_process_host_impl.cc:609: media::AudioManager::StartHangMonitor( Doesn't this blow up if being called repeatedly? Maybe just needs a 'if (!BrowserMainLoop::GetInstance()->audio_manager())'?
https://codereview.chromium.org/2077983003/diff/80001/content/browser/rendere... File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2077983003/diff/80001/content/browser/rendere... content/browser/renderer_host/render_process_host_impl.cc:609: media::AudioManager::StartHangMonitor( On 2016/06/21 23:57:22, sievers wrote: > Doesn't this blow up if being called repeatedly? > > Maybe just needs a 'if (!BrowserMainLoop::GetInstance()->audio_manager())'? That doesn't work in ChromeOS case though since audio_manager() is already created before renderer process are created. I changed the AudioManagerHelper::StartHangTimer() to abort early if this is already called.
lgtm https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... content/browser/renderer_host/render_process_host_impl.cc:608: // necessary or recommended. nit: Can you put a comment that we intentionally defer watchdog creation until we start a renderer? Maybe it should also be called 'Start..IfNecessary()' or something?
Patchset #6 (id:120001) has been deleted
Patchset #6 (id:140001) has been deleted
Patchset #6 (id:160001) has been deleted
Patchset #6 (id:180001) has been deleted
Patchset #6 (id:200001) has been deleted
Patchset #6 (id:220001) has been deleted
Patchset #6 (id:240001) has been deleted
On 2016/06/22 00:31:18, sievers wrote: > lgtm > > https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... > File content/browser/renderer_host/render_process_host_impl.cc (right): > > https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... > content/browser/renderer_host/render_process_host_impl.cc:608: // necessary or > recommended. > nit: Can you put a comment that we intentionally defer watchdog creation until > we start a renderer? > > Maybe it should also be called 'Start..IfNecessary()' or something?
https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2077983003/diff/100001/content/browser/render... content/browser/renderer_host/render_process_host_impl.cc:608: // necessary or recommended. On 2016/06/22 00:31:18, sievers wrote: > nit: Can you put a comment that we intentionally defer watchdog creation until > we start a renderer? > > Maybe it should also be called 'Start..IfNecessary()' or something? Done.
The CQ bit was checked by qinmin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from dalecurtis@chromium.org, sievers@chromium.org Link to the patchset: https://codereview.chromium.org/2077983003/#ps260001 (title: "fix test and lazy init jobj")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by qinmin@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
Patchset #7 (id:280001) has been deleted
Patchset #7 (id:300001) has been deleted
The CQ bit was checked by qinmin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from dalecurtis@chromium.org, sievers@chromium.org Link to the patchset: https://codereview.chromium.org/2077983003/#ps320001 (title: "fix MediaSessionTest")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
Patchset #7 (id:320001) has been deleted
The CQ bit was checked by qinmin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by qinmin@chromium.org
The CQ bit was checked by qinmin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from dalecurtis@chromium.org, sievers@chromium.org Link to the patchset: https://codereview.chromium.org/2077983003/#ps340001 (title: "fix MediaSessionTest")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by qinmin@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager takes about 10KB of memory. This is only needed when the first renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 ========== to ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager takes about 10KB of memory. This is only needed when the first renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 ==========
Message was sent while issue was closed.
Committed patchset #7 (id:340001)
Message was sent while issue was closed.
CQ bit was unchecked.
Message was sent while issue was closed.
Description was changed from ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager takes about 10KB of memory. This is only needed when the first renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 ========== to ========== Intiialize AudioManager and related class lazily AudioManager is created when browser process is created. However, for background download resumption, we don't need AudioManager for download to resume. Creating the AudioManager takes about 10KB of memory. This is only needed when the first renderer is created. This CL delays AudioManager creation until it is first referenced. This also involves some other classes that depends on AudioManager. BUG=620479 Committed: https://crrev.com/c8569a7cd8c3cb6f9cd22467e084860721ceadd7 Cr-Commit-Position: refs/heads/master@{#404014} ==========
Message was sent while issue was closed.
Patchset 7 (id:??) landed as https://crrev.com/c8569a7cd8c3cb6f9cd22467e084860721ceadd7 Cr-Commit-Position: refs/heads/master@{#404014} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
