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

Unified Diff: content/gpu/gpu_watchdog_thread.cc

Issue 836473003: Avoid gpu watchdog crash on timeout if X is un-responsive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: create new display and explicitly catch change in prop in watchdog thread. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/gpu/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/gpu/gpu_watchdog_thread.cc
diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc
index 02b6bff8040e8f6c7c464f309c31761da0f508f9..1462f09fc1d9a3210494a5a72ed9335f96770fd7 100644
--- a/content/gpu/gpu_watchdog_thread.cc
+++ b/content/gpu/gpu_watchdog_thread.cc
@@ -39,6 +39,12 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
#endif
task_observer_(this),
suspended_(false),
+#if defined(USE_X11)
+ x_server_active_(true),
+ display_(NULL),
+ window_(1),
piman 2015/02/04 01:03:05 why 1?
sohanjg 2015/02/06 10:40:58 Done.
+ atom_(None),
+#endif
weak_factory_(this) {
DCHECK(timeout >= 0);
@@ -59,6 +65,9 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
#if defined(OS_CHROMEOS)
tty_file_ = base::OpenFile(base::FilePath(kTtyFilePath), "r");
#endif
+#if defined(USE_X11)
+ SetupXServer();
+#endif
watched_message_loop_->AddTaskObserver(&task_observer_);
}
@@ -184,14 +193,25 @@ void GpuWatchdogThread::OnCheck(bool after_suspend) {
FROM_HERE,
base::Bind(&base::DoNothing));
- // Post a task to the watchdog thread to exit if the monitored thread does
- // not respond in time.
+#if defined(USE_X11)
+ // Post a task to the watchdog thread to check XServer is active
+ // if the monitored thread does not respond in time.
+ SetupXChangeProp();
message_loop()->PostDelayedTask(
sohanjg 2015/02/02 14:17:19 Should we post a delayed task here, or explicitly
- FROM_HERE,
- base::Bind(
- &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang,
- weak_factory_.GetWeakPtr()),
+ FROM_HERE, base::Bind(&GpuWatchdogThread::CheckXServerActive,
+ weak_factory_.GetWeakPtr()),
timeout);
+ if (!x_server_active_)
+#endif
+ {
+ // Post a task to the watchdog thread to exit if the monitored thread does
+ // not respond in time.
+ message_loop()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang,
+ weak_factory_.GetWeakPtr()),
+ timeout);
+ }
}
// Use the --disable-gpu-watchdog command line switch to disable this.
@@ -259,6 +279,37 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
terminated = true;
}
+#if defined(USE_X11)
+void GpuWatchdogThread::CheckXServerActive() {
+ unsigned long nitems = 0;
+ unsigned long nbytes = 0;
+ XAtom prop_type = None;
+ int prop_format = 0;
+ unsigned char* property_data = NULL;
+ if (XGetWindowProperty(display_, window_, atom_, 0, 65535, False,
+ AnyPropertyType, &prop_type, &prop_format, &nitems,
+ &nbytes, &property_data) == Success) {
piman 2015/02/04 01:03:05 If X is blocked, this will block. I don't think th
sohanjg 2015/02/06 10:40:58 Done.
+ if (prop_type == XA_STRING && prop_format == 8 && nitems == 5) {
+ x_server_active_ = true;
+ return;
+ }
+ }
+ x_server_active_ = false;
+}
+
+void GpuWatchdogThread::SetupXServer() {
+ display_ = XOpenDisplay(NULL);
+ window_ = XCreateWindow(display_, DefaultRootWindow(display_), 0, 0, 1, 1, 0,
+ CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
+}
+
+void GpuWatchdogThread::SetupXChangeProp() {
+ unsigned char text[20] = "check";
+ atom_ = XInternAtom(display_, "CHK", False);
+ XChangeProperty(display_, window_, atom_, XA_STRING, 8, PropModeReplace, text,
+ 5);
+}
+#endif
void GpuWatchdogThread::AddPowerObserver() {
message_loop()->PostTask(
FROM_HERE,
« no previous file with comments | « content/gpu/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698