summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 22:38:44 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 22:38:44 +0000
commit983c33d1bb96295f94d8de04c7d70de216169473 (patch)
tree15f000d516a4211d2c5f56e910536b5ee5647e3a /chrome/gpu
parente2356245e357455e99aade6a0800032b115c1b53 (diff)
downloadchromium_src-983c33d1bb96295f94d8de04c7d70de216169473.zip
chromium_src-983c33d1bb96295f94d8de04c7d70de216169473.tar.gz
chromium_src-983c33d1bb96295f94d8de04c7d70de216169473.tar.bz2
Call GpuThread::Init before starting the GPU watchdog thread.
Collecting GPU info was taking enough time to make the GPU watchdog abort the GPU process. Moved GTK initialization into GpuProcess (but still before gfx::GLContext::InitializeOneOff). TEST=try BUG=none Review URL: http://codereview.chromium.org/5017004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_main.cc37
-rw-r--r--chrome/gpu/gpu_thread.cc18
2 files changed, 21 insertions, 34 deletions
diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc
index 7ee9622c..4e4248d 100644
--- a/chrome/gpu/gpu_main.cc
+++ b/chrome/gpu/gpu_main.cc
@@ -32,9 +32,9 @@
#if defined(USE_X11)
#include "app/x11_util.h"
#include "app/x11_util_internal.h"
+#include "gfx/gtk_util.h"
#endif
-
namespace {
// 1% per watchdog trial group.
@@ -87,22 +87,31 @@ int GpuMain(const MainFunctionParams& parameters) {
#endif
#if defined(USE_X11)
+ // The X11 port of the command buffer code assumes it can access the X
+ // display via the macro GDK_DISPLAY(), which implies that Gtk has been
+ // initialized. This code was taken from PluginThread. TODO(kbr):
+ // rethink whether initializing Gtk is really necessary or whether we
+ // should just send a raw display connection down to the GPUProcessor.
+ g_thread_init(NULL);
+ gfx::GtkInitFromCommandLine(command_line);
SetGpuX11ErrorHandlers();
#endif
- // On Linux the GpuThread constructor performs certain
- // initialization that is required before accessing the default X
- // display.
+ // Load the GL implementation and locate the bindings before starting the GPU
+ // watchdog because this can take a lot of time and the GPU watchdog might
+ // terminate the GPU process.
+ if (!gfx::GLContext::InitializeOneOff())
+ return EXIT_FAILURE;
+
+ // Do this soon before running the message loop so accurate
+ // initialization time is recorded in the GPU info. Don't do it before
+ // starting the watchdog thread since it can take a significant amount of
+ // time to collect GPU information in GpuThread::Init.
GpuProcess gpu_process;
GpuThread* gpu_thread = new GpuThread;
+ gpu_thread->Init(start_time);
gpu_process.set_main_thread(gpu_thread);
- // Load the GL implementation and locate the bindings before starting as
- // this can take a lot of time and the GPU watchdog might terminate the GPU
- // process.
- if (!gfx::GLContext::InitializeOneOff())
- return EXIT_FAILURE;
-
// Only enable this experimental feaure for a subset of users.
scoped_refptr<base::FieldTrial> watchdog_trial(
new base::FieldTrial("GpuWatchdogTrial", 100));
@@ -116,8 +125,6 @@ int GpuMain(const MainFunctionParams& parameters) {
}
}
- scoped_ptr<base::Environment> env(base::Environment::Create());
-
// In addition to disabling the watchdog if the command line switch is
// present, disable it in two other cases. OSMesa is expected to run very
// slowly. Also disable the watchdog on valgrind because the code is expected
@@ -134,6 +141,8 @@ int GpuMain(const MainFunctionParams& parameters) {
enable_watchdog = false;
#endif
+ // Start the GPU watchdog only after anything that is expected to be time
+ // consuming has completed, otherwise the process is liable to be aborted.
scoped_refptr<GpuWatchdogThread> watchdog_thread;
if (enable_watchdog) {
watchdog_thread = new GpuWatchdogThread(MessageLoop::current(),
@@ -141,10 +150,6 @@ int GpuMain(const MainFunctionParams& parameters) {
watchdog_thread->Start();
}
- // Do this immediately before running the message loop so the correct
- // initialization time is recorded in the GPU info.
- gpu_thread->Init(start_time);
-
main_message_loop.Run();
if (enable_watchdog)
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc
index e278bec..dc12737 100644
--- a/chrome/gpu/gpu_thread.cc
+++ b/chrome/gpu/gpu_thread.cc
@@ -21,25 +21,7 @@
#include "app/win_util.h"
#endif
-#if defined(TOOLKIT_USES_GTK)
-#include <gtk/gtk.h>
-#include "app/x11_util.h"
-#include "gfx/gtk_util.h"
-#endif
-
GpuThread::GpuThread() {
-#if defined(OS_LINUX)
- {
- // The X11 port of the command buffer code assumes it can access the X
- // display via the macro GDK_DISPLAY(), which implies that Gtk has been
- // initialized. This code was taken from PluginThread. TODO(kbr):
- // rethink whether initializing Gtk is really necessary or whether we
- // should just send a raw display connection down to the GPUProcessor.
- g_thread_init(NULL);
- gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess());
- x11_util::SetDefaultX11ErrorHandlers();
- }
-#endif
}
GpuThread::~GpuThread() {