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

Unified Diff: content/gpu/gpu_watchdog_thread.cc

Issue 1991353002: Don't restart the GPU process when switching to another TTY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't exit the GPU process if on a non-host TTY Created 4 years, 7 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 dddb40945af57816ceb155bd932c7a3603cfe69d..68ba816ed8c831850ecc29ca1a7a1b44ba6b327b 100644
--- a/content/gpu/gpu_watchdog_thread.cc
+++ b/content/gpu/gpu_watchdog_thread.cc
@@ -29,11 +29,9 @@
namespace content {
namespace {
-#if defined(OS_CHROMEOS)
+#if defined(USE_X11)
const base::FilePath::CharType
kTtyFilePath[] = FILE_PATH_LITERAL("/sys/class/tty/tty0/active");
-#endif
-#if defined(USE_X11)
const unsigned char text[20] = "check";
#endif
} // namespace
@@ -55,6 +53,7 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
display_(NULL),
window_(0),
atom_(None),
+ host_tty_(-1),
#endif
weak_factory_(this) {
DCHECK(timeout >= 0);
@@ -73,10 +72,8 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
DCHECK(result);
#endif
-#if defined(OS_CHROMEOS)
- tty_file_ = base::OpenFile(base::FilePath(kTtyFilePath), "r");
-#endif
#if defined(USE_X11)
+ tty_file_ = base::OpenFile(base::FilePath(kTtyFilePath), "r");
SetupXServer();
#endif
watched_message_loop_->AddTaskObserver(&task_observer_);
@@ -136,12 +133,9 @@ GpuWatchdogThread::~GpuWatchdogThread() {
if (power_monitor)
power_monitor->RemoveObserver(this);
-#if defined(OS_CHROMEOS)
+#if defined(USE_X11)
if (tty_file_)
fclose(tty_file_);
-#endif
-
-#if defined(USE_X11)
XDestroyWindow(display_, window_);
XCloseDisplay(display_);
#endif
@@ -325,17 +319,11 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
return;
#endif
-#if defined(OS_CHROMEOS)
- // Don't crash if we're not on tty1. This avoids noise in the GPU process
- // crashes caused by people who use VT2 but still enable crash reporting.
- char tty_string[8] = {0};
- if (tty_file_ &&
- !fseek(tty_file_, 0, SEEK_SET) &&
- fread(tty_string, 1, 7, tty_file_)) {
- int tty_number = -1;
- int num_res = sscanf(tty_string, "tty%d", &tty_number);
- if (num_res == 1 && tty_number != 1)
- return;
+#if defined(USE_X11)
+ // Don't crash if we're not on the TTY of our host X11 server.
+ int active_tty = GetActiveTTY();
+ if(host_tty_ != -1 && active_tty != -1 && host_tty_ != active_tty) {
+ return;
}
#endif
@@ -380,6 +368,7 @@ void GpuWatchdogThread::SetupXServer() {
window_ = XCreateWindow(display_, DefaultRootWindow(display_), 0, 0, 1, 1, 0,
CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
atom_ = XInternAtom(display_, "CHECK", False);
+ host_tty_ = GetActiveTTY();
}
void GpuWatchdogThread::SetupXChangeProp() {
@@ -463,4 +452,18 @@ base::ThreadTicks GpuWatchdogThread::GetWatchedThreadTime() {
}
#endif
+#if defined(USE_X11)
+int GpuWatchdogThread::GetActiveTTY() const {
+ char tty_string[8] = {0};
+ if (tty_file_ && !fseek(tty_file_, 0, SEEK_SET) &&
+ fread(tty_string, 1, 7, tty_file_)) {
+ int tty_number;
+ size_t num_res = sscanf(tty_string, "tty%d\n", &tty_number);
+ if (num_res == 1)
+ return tty_number;
+ }
+ return -1;
+}
+#endif
+
} // namespace content
« 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