Commit 1620bd3a authored by dalecurtis's avatar dalecurtis Committed by Commit bot

Switch audio hang monitor to default-off. Enable for non-beta,stable.

Too many crashes and out of ideas for how to resolve this for right
now; this at least provides the chance that these users might unhang
themselves some time after the 2 minute hang timer.

BUG=422522, 468074, 478932
TEST=start w/ and w/o hang monitor according to channel, flags.

Review URL: https://codereview.chromium.org/1105083004

Cr-Commit-Position: refs/heads/master@{#327356}
parent 83ee45ba
......@@ -116,6 +116,7 @@ include_rules = [
"+grit", # TODO(thestig) Remove. For generated headers
"+installer_util_strings", # For generated headers
"+jni",
"+media/audio", # For media audio hang monitor.
"+media/base", # For media switches
"+policy", # For generated headers and source
"+ppapi/c", # For various types.
......
......@@ -134,6 +134,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "grit/platform_locale_settings.h"
#include "media/audio/audio_manager.h"
#include "net/base/net_module.h"
#include "net/cookies/cookie_monster.h"
#include "net/http/http_network_layer.h"
......@@ -673,8 +674,18 @@ void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() {
// Now that field trials have been created, initializes metrics recording.
metrics->InitializeMetricsRecordingState();
const chrome::VersionInfo::Channel channel =
chrome::VersionInfo::GetChannel();
// TODO(dalecurtis): Remove these checks and enable for all channels once we
// track down the root causes of crbug.com/422522 and crbug.com/478932.
if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
chrome::VersionInfo::CHANNEL_CANARY || chrome::VersionInfo::CHANNEL_DEV) {
media::AudioManager::EnableHangMonitor();
}
// Enable profiler instrumentation depending on the channel.
switch (chrome::VersionInfo::GetChannel()) {
switch (channel) {
case chrome::VersionInfo::CHANNEL_UNKNOWN:
case chrome::VersionInfo::CHANNEL_CANARY:
tracked_objects::ScopedTracker::Enable();
......
......@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/debug/alias.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
......@@ -14,6 +15,7 @@
#include "build/build_config.h"
#include "media/audio/audio_manager_factory.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/base/media_switches.h"
namespace media {
namespace {
......@@ -131,6 +133,8 @@ class AudioManagerHelper : public base::PowerObserver {
DISALLOW_COPY_AND_ASSIGN(AudioManagerHelper);
};
static bool g_hang_monitor_enabled = false;
static base::LazyInstance<AudioManagerHelper>::Leaky g_helper =
LAZY_INSTANCE_INITIALIZER;
} // namespace
......@@ -177,11 +181,11 @@ AudioManager* AudioManager::CreateWithHangTimer(
AudioLogFactory* audio_log_factory,
const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner) {
AudioManager* manager = Create(audio_log_factory);
// On OSX the audio thread is the UI thread, for which a hang monitor is not
// necessary.
#if !defined(OS_MACOSX)
if (g_hang_monitor_enabled ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAudioHangMonitor)) {
g_helper.Pointer()->StartHangTimer(monitor_task_runner);
#endif
}
return manager;
}
......@@ -190,6 +194,17 @@ AudioManager* AudioManager::CreateForTesting() {
return Create(g_helper.Pointer()->fake_log_factory());
}
// static
void AudioManager::EnableHangMonitor() {
CHECK(!g_last_created);
// On OSX the audio thread is the UI thread, for which a hang monitor is not
// necessary or recommended. If it's manually requested, we should allow it
// to start though.
#if !defined(OS_MACOSX)
g_hang_monitor_enabled = true;
#endif
}
// static
AudioManager* AudioManager::Get() {
return g_last_created;
......
......@@ -47,7 +47,7 @@ class MEDIA_EXPORT AudioManager {
// Similar to Create() except also schedules a monitor on the given task
// runner to ensure the audio thread is not stuck for more than 60 seconds; if
// a hang is detected, the process will be crashed.
// a hang is detected, the process will be crashed. See EnableHangMonitor().
static AudioManager* CreateWithHangTimer(
AudioLogFactory* audio_log_factory,
const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner);
......@@ -55,6 +55,12 @@ class MEDIA_EXPORT AudioManager {
// Similar to Create() except uses a FakeAudioLogFactory for testing.
static AudioManager* CreateForTesting();
// Enables the hang monitor for the AudioManager once it's created. Must be
// called before the AudioManager is created. CreateWithHangTimer() requires
// either switches::kEnableAudioHangMonitor to be present or this to have been
// called previously to start the hang monitor. Does nothing on OSX.
static void EnableHangMonitor();
// Should only be used for testing. Resets a previously-set
// AudioManagerFactory. The instance of AudioManager is not affected.
static void ResetFactoryForTesting();
......
......@@ -84,6 +84,11 @@ const char kWaveOutBuffers[] = "waveout-buffers";
const char kUseCras[] = "use-cras";
#endif
// Enables the audio thread hang monitor. Allows us to find users in the field
// who have stuck audio threads. See crbug.com/422522 and crbug.com/478932.
// TODO(dalecurtis): This should be removed once those issues are resolved.
const char kEnableAudioHangMonitor[] = "enable-audio-hang-monitor";
// Use fake device for Media Stream to replace actual camera and microphone.
const char kUseFakeDeviceForMediaStream[] = "use-fake-device-for-media-stream";
......
......@@ -46,6 +46,8 @@ MEDIA_EXPORT extern const char kWaveOutBuffers[];
MEDIA_EXPORT extern const char kUseCras[];
#endif
MEDIA_EXPORT extern const char kEnableAudioHangMonitor[];
MEDIA_EXPORT extern const char kUseFakeDeviceForMediaStream[];
MEDIA_EXPORT extern const char kUseFileForFakeVideoCapture[];
MEDIA_EXPORT extern const char kUseFileForFakeAudioCapture[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment