GPU process terminates rather than crashing on hang.
Hangs are reported via exit code.
BUG=74564,90406,74588
Review URL: http://codereview.chromium.org/7646031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97359 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 38942c7..73184ddb 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -19,6 +19,7 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/common/content_switches.h"
#include "content/common/gpu/gpu_messages.h"
+#include "content/common/result_codes.h"
#include "content/gpu/gpu_child_thread.h"
#include "content/gpu/gpu_process.h"
#include "ipc/ipc_channel_handle.h"
@@ -484,10 +485,16 @@
UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents",
DIED_FIRST_TIME + g_gpu_crash_count,
GPU_PROCESS_LIFETIME_EVENT_MAX);
- base::TerminationStatus status = GetChildTerminationStatus(NULL);
+
+ int exit_code;
+ base::TerminationStatus status = GetChildTerminationStatus(&exit_code);
UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus",
status,
base::TERMINATION_STATUS_MAX_ENUM);
+ UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode",
+ exit_code,
+ content::RESULT_CODE_LAST_CODE);
+
BrowserChildProcessHost::OnChildDied();
}
diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc
index 3f772078..4e2f7fb 100644
--- a/content/gpu/gpu_watchdog_thread.cc
+++ b/content/gpu/gpu_watchdog_thread.cc
@@ -9,7 +9,10 @@
#include "content/gpu/gpu_watchdog_thread.h"
#include "base/compiler_specific.h"
+#include "base/process_util.h"
+#include "base/process.h"
#include "build/build_config.h"
+#include "content/common/result_codes.h"
namespace {
const int64 kCheckPeriod = 2000;
@@ -186,12 +189,12 @@
message_loop()->PostDelayedTask(
FROM_HERE,
method_factory_->NewRunnableMethod(
- &GpuWatchdogThread::DeliberatelyCrashingToRecoverFromHang),
+ &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang),
timeout_);
}
// Use the --disable-gpu-watchdog command line switch to disable this.
-void GpuWatchdogThread::DeliberatelyCrashingToRecoverFromHang() {
+void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
#if defined(OS_WIN)
// Defer termination until a certain amount of CPU time has elapsed on the
// watched thread.
@@ -200,7 +203,7 @@
message_loop()->PostDelayedTask(
FROM_HERE,
method_factory_->NewRunnableMethod(
- &GpuWatchdogThread::DeliberatelyCrashingToRecoverFromHang),
+ &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang),
timeout_ - time_since_arm);
return;
}
@@ -217,12 +220,11 @@
return;
}
- // Make sure the timeout period is on the stack before crashing.
- volatile int timeout = timeout_;
-
- // For minimal developer annoyance, don't keep crashing.
- static bool crashed = false;
- if (crashed)
+ // For minimal developer annoyance, don't keep terminating. You need to skip
+ // the call to base::Process::Terminate below in a debugger for this to be
+ // useful.
+ static bool terminated = false;
+ if (terminated)
return;
#if defined(OS_WIN)
@@ -233,8 +235,8 @@
LOG(ERROR) << "The GPU process hung. Terminating after "
<< timeout_ << " ms.";
- volatile int* null_pointer = NULL;
- *null_pointer = timeout;
+ base::Process current_process(base::GetCurrentProcessHandle());
+ current_process.Terminate(content::RESULT_CODE_HUNG);
- crashed = true;
+ terminated = true;
}
diff --git a/content/gpu/gpu_watchdog_thread.h b/content/gpu/gpu_watchdog_thread.h
index 08e4612..e3054c38 100644
--- a/content/gpu/gpu_watchdog_thread.h
+++ b/content/gpu/gpu_watchdog_thread.h
@@ -52,7 +52,7 @@
void OnAcknowledge();
void OnCheck();
- void DeliberatelyCrashingToRecoverFromHang();
+ void DeliberatelyTerminateToRecoverFromHang();
void Disable();
int64 GetWatchedThreadTime();