diff options
28 files changed, 118 insertions, 475 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 432474a..3cba7dc 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -762,38 +762,28 @@ std::string AboutGpu() { html.append("</body></html> "); } else { html.append("<html><head><title>About GPU</title></head><body>\n"); - html.append("<h2>GPU Information</h2>\n"); - html.append("<table><tr>"); - html.append("<td><strong>Initialization time</strong></td><td>"); - html.append(base::Int64ToString( - gpu_info.initialization_time().InMilliseconds())); - html.append("</td></tr><tr><td>"); - html.append("<strong>Vendor ID</strong></td><td>"); + html.append("<h2>GPU Information</h2><ul>\n"); + html.append("<li><strong>Vendor ID:</strong> "); html.append(base::StringPrintf("0x%04x", gpu_info.vendor_id())); - html.append("</td></tr><tr><td>"); - html.append("<strong>Device ID</strong></td><td>"); + html.append("<li><strong>Device ID:</strong> "); html.append(base::StringPrintf("0x%04x", gpu_info.device_id())); - html.append("</td></tr><tr><td>"); - html.append("<strong>Driver Version</strong></td><td>"); + html.append("<li><strong>Driver Version:</strong> "); html.append(WideToASCII(gpu_info.driver_version()).c_str()); - html.append("</td></tr><tr><td>"); - html.append("<strong>Pixel Shader Version</strong></td><td>"); - html.append(VersionNumberToString(gpu_info.pixel_shader_version()).c_str()); - html.append("</td></tr><tr><td>"); - html.append("<strong>Vertex Shader Version</strong></td><td>"); + html.append("<li><strong>Pixel Shader Version:</strong> "); + html.append(VersionNumberToString( + gpu_info.pixel_shader_version()).c_str()); + html.append("<li><strong>Vertex Shader Version:</strong> "); html.append(VersionNumberToString( - gpu_info.vertex_shader_version()).c_str()); - html.append("</td></tr><tr><td>"); - html.append("<strong>GL Version</strong></td><td>"); + gpu_info.vertex_shader_version()).c_str()); + html.append("<li><strong>GL Version:</strong> "); html.append(VersionNumberToString(gpu_info.gl_version()).c_str()); - html.append("</td></tr></table>"); #if defined(OS_WIN) - html.append("<h2>DirectX Diagnostics</h2>"); + html.append("<li><strong>DirectX Diagnostics:</strong> "); DxDiagNodeToHTML(&html, gpu_info.dx_diagnostics()); #endif - html.append("</body></html>"); + html.append("</ul></body></html> "); } return html; } @@ -1130,11 +1120,11 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { // Handle URLs to wreck the gpu process. if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCrashURL)) { - GpuProcessHostUIShim::Get()->SendAboutGpuCrash(); + GpuProcessHost::SendAboutGpuCrash(); return true; } if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuHangURL)) { - GpuProcessHostUIShim::Get()->SendAboutGpuHang(); + GpuProcessHost::SendAboutGpuHang(); return true; } diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index b9e26e3..a33ef5c 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -94,7 +94,6 @@ bool GpuProcessHost::Init() { static const char* const kSwitchNames[] = { switches::kUseGL, switches::kDisableGpuVsync, - switches::kDisableGpuWatchdog, switches::kDisableLogging, switches::kEnableAcceleratedDecoding, switches::kEnableLogging, @@ -127,6 +126,16 @@ GpuProcessHost* GpuProcessHost::Get() { return sole_instance_; } +// static +void GpuProcessHost::SendAboutGpuCrash() { + Get()->Send(new GpuMsg_Crash()); +} + +// static +void GpuProcessHost::SendAboutGpuHang() { + Get()->Send(new GpuMsg_Hang()); +} + bool GpuProcessHost::Send(IPC::Message* msg) { if (!EnsureInitialized()) return false; diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index 68e0496..0e14402 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -28,6 +28,13 @@ class GpuProcessHost : public BrowserChildProcessHost { // Getter for the singleton. This will return NULL on failure. static GpuProcessHost* Get(); + // Tells the GPU process to crash. Useful for testing. + static void SendAboutGpuCrash(); + + // Tells the GPU process to let its main thread enter an infinite loop. + // Useful for testing. + static void SendAboutGpuHang(); + // Shutdown routine, which should only be called upon process // termination. static void Shutdown(); diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc index 9ab296d..71db44b 100644 --- a/chrome/browser/gpu_process_host_ui_shim.cc +++ b/chrome/browser/gpu_process_host_ui_shim.cc @@ -74,19 +74,3 @@ void GpuProcessHostUIShim::CollectGraphicsInfoAsynchronously() { FROM_HERE, new SendOnIOThreadTask(new GpuMsg_CollectGraphicsInfo())); } - -void GpuProcessHostUIShim::SendAboutGpuCrash() { - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - new SendOnIOThreadTask(new GpuMsg_Crash())); -} - -void GpuProcessHostUIShim::SendAboutGpuHang() { - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - new SendOnIOThreadTask(new GpuMsg_Hang())); -} diff --git a/chrome/browser/gpu_process_host_ui_shim.h b/chrome/browser/gpu_process_host_ui_shim.h index a65f29c..3e5d93b 100644 --- a/chrome/browser/gpu_process_host_ui_shim.h +++ b/chrome/browser/gpu_process_host_ui_shim.h @@ -46,13 +46,6 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender, // graphics card. void CollectGraphicsInfoAsynchronously(); - // Tells the GPU process to crash. Useful for testing. - void SendAboutGpuCrash(); - - // Tells the GPU process to let its main thread enter an infinite loop. - // Useful for testing. - void SendAboutGpuHang(); - private: friend struct DefaultSingletonTraits<GpuProcessHostUIShim>; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 35bc0ef..91a4636 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -724,8 +724,6 @@ 'gpu/gpu_video_service.h', 'gpu/gpu_view_win.cc', 'gpu/gpu_view_win.h', - 'gpu/gpu_watchdog_thread.cc', - 'gpu/gpu_watchdog_thread.h', 'gpu/media/gpu_video_device.h', 'gpu/media/fake_gl_video_decode_engine.cc', 'gpu/media/fake_gl_video_decode_engine.h', @@ -741,7 +739,6 @@ '<(DEPTH)/third_party/angle/include', '<(DEPTH)/third_party/angle/src', '<(DEPTH)/third_party/wtl/include', - '$(DXSDK_DIR)/include', ], 'dependencies': [ '../third_party/angle/src/build_angle.gyp:libEGL', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 6534a6b..704171d 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -455,7 +455,6 @@ '../third_party/icu/icu.gyp:icuuc', '../third_party/libxml/libxml.gyp:libxml', # run time dependencies - '../third_party/mesa/mesa.gyp:osmesa', 'default_plugin/default_plugin.gyp:default_plugin', '../third_party/ppapi/ppapi.gyp:ppapi_tests', '../webkit/support/webkit_support.gyp:copy_npapi_layout_test_plugin', @@ -523,6 +522,7 @@ ['target_arch!="x64" and target_arch!="arm"', { 'dependencies': [ '../webkit/webkit.gyp:copy_npapi_test_plugin', + '../third_party/mesa/mesa.gyp:osmesa', ], }], # Only copy the pepper plugin on Windows which is the only platform diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 9263dd7..ba116a4 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -194,10 +194,6 @@ const char kDisableGeolocation[] = "disable-geolocation"; // Disable the GLSL translator. const char kDisableGLSLTranslator[] = "disable-glsl-translator"; -// Disable the thread that crashes the GPU process if it stops responding to -// messages. -const char kDisableGpuWatchdog[] = "disable-gpu-watchdog"; - // Suppresses hang monitor dialogs in renderer processes. This may allow slow // unload handlers on a page to prevent the tab from closing, but the Task // Manager can be used to terminate the offending process in this case. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 3ac43ba..ffd8dfe 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -67,7 +67,6 @@ extern const char kDisableExtensions[]; extern const char kDisableFileSystem[]; extern const char kDisableGLSLTranslator[]; extern const char kDisableGeolocation[]; -extern const char kDisableGpuWatchdog[]; extern const char kDisableHangMonitor[]; extern const char kDisableHistoryQuickProvider[]; extern const char kDisableHistoryURLProvider[]; diff --git a/chrome/common/gpu_info.cc b/chrome/common/gpu_info.cc index 64f0498..667c375 100644 --- a/chrome/common/gpu_info.cc +++ b/chrome/common/gpu_info.cc @@ -16,10 +16,6 @@ bool GPUInfo::initialized() const { return initialized_; } -base::TimeDelta GPUInfo::initialization_time() const { - return initialization_time_; -} - uint32 GPUInfo::vendor_id() const { return vendor_id_; } @@ -49,12 +45,6 @@ bool GPUInfo::can_lose_context() const { return can_lose_context_; } -void GPUInfo::SetInitializationTime( - const base::TimeDelta& initialization_time) { - initialization_time_ = initialization_time; -} - - void GPUInfo::SetGraphicsInfo(uint32 vendor_id, uint32 device_id, const std::wstring& driver_version, uint32 pixel_shader_version, diff --git a/chrome/common/gpu_info.h b/chrome/common/gpu_info.h index bdf8709..50728db 100644 --- a/chrome/common/gpu_info.h +++ b/chrome/common/gpu_info.h @@ -12,7 +12,6 @@ #include <string> #include "base/basictypes.h" -#include "base/time.h" #include "build/build_config.h" #include "chrome/common/dx_diag_node.h" @@ -24,10 +23,6 @@ class GPUInfo { // Returns whether this GPUInfo has been initialized with information bool initialized() const; - // The amount of time taken to get from the process starting to the message - // loop being pumped. - base::TimeDelta initialization_time() const; - // Return the DWORD (uint32) representing the graphics card vendor id. uint32 vendor_id() const; @@ -60,8 +55,6 @@ class GPUInfo { // semantics are available. bool can_lose_context() const; - void SetInitializationTime(const base::TimeDelta& initialization_time); - // Populate variables with passed in values void SetGraphicsInfo(uint32 vendor_id, uint32 device_id, const std::wstring& driver_version, @@ -79,7 +72,6 @@ class GPUInfo { private: bool initialized_; - base::TimeDelta initialization_time_; uint32 vendor_id_; uint32 device_id_; std::wstring driver_version_; diff --git a/chrome/common/gpu_messages.cc b/chrome/common/gpu_messages.cc index e138a43..db7f597 100644 --- a/chrome/common/gpu_messages.cc +++ b/chrome/common/gpu_messages.cc @@ -10,7 +10,6 @@ #include "gfx/rect.h" #include "gfx/size.h" #include "ipc/ipc_channel_handle.h" -#include "ipc/ipc_message_utils.h" #define MESSAGES_INTERNAL_IMPL_FILE \ "chrome/common/gpu_messages_internal.h" @@ -81,7 +80,6 @@ void ParamTraits<GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params> ::Log( #endif // if defined(OS_MACOSX) void ParamTraits<GPUInfo> ::Write(Message* m, const param_type& p) { - ParamTraits<base::TimeDelta> ::Write(m, p.initialization_time()); m->WriteUInt32(p.vendor_id()); m->WriteUInt32(p.device_id()); m->WriteWString(p.driver_version()); @@ -96,7 +94,6 @@ void ParamTraits<GPUInfo> ::Write(Message* m, const param_type& p) { } bool ParamTraits<GPUInfo> ::Read(const Message* m, void** iter, param_type* p) { - base::TimeDelta initialization_time; uint32 vendor_id; uint32 device_id; std::wstring driver_version; @@ -104,15 +101,13 @@ bool ParamTraits<GPUInfo> ::Read(const Message* m, void** iter, param_type* p) { uint32 vertex_shader_version; uint32 gl_version; bool can_lose_context; - bool ret = ParamTraits<base::TimeDelta> ::Read(m, iter, &initialization_time); - ret = ret && m->ReadUInt32(iter, &vendor_id); + bool ret = m->ReadUInt32(iter, &vendor_id); ret = ret && m->ReadUInt32(iter, &device_id); ret = ret && m->ReadWString(iter, &driver_version); ret = ret && m->ReadUInt32(iter, &pixel_shader_version); ret = ret && m->ReadUInt32(iter, &vertex_shader_version); ret = ret && m->ReadUInt32(iter, &gl_version); ret = ret && m->ReadBool(iter, &can_lose_context); - p->SetInitializationTime(initialization_time); p->SetGraphicsInfo(vendor_id, device_id, driver_version, @@ -131,9 +126,7 @@ bool ParamTraits<GPUInfo> ::Read(const Message* m, void** iter, param_type* p) { } void ParamTraits<GPUInfo> ::Log(const param_type& p, std::string* l) { - l->append(StringPrintf("<GPUInfo> %d %x %x %ls %d", - static_cast<int32>( - p.initialization_time().InMilliseconds()), + l->append(StringPrintf("<GPUInfo> %x %x %ls %d", p.vendor_id(), p.device_id(), p.driver_version().c_str(), diff --git a/chrome/common/gpu_messages_unittest.cc b/chrome/common/gpu_messages_unittest.cc index 59d42ed..455458f 100644 --- a/chrome/common/gpu_messages_unittest.cc +++ b/chrome/common/gpu_messages_unittest.cc @@ -13,7 +13,6 @@ TEST(GPUIPCMessageTest, GPUInfo) { GPUInfo input; // Test variables taken from Lenovo T61 - input.SetInitializationTime(base::TimeDelta::FromMilliseconds(100)); input.SetGraphicsInfo(0x10de, 0x429, L"6.14.11.7715", 0xffff0300, 0xfffe0300, @@ -26,8 +25,6 @@ TEST(GPUIPCMessageTest, GPUInfo) { GPUInfo output; void* iter = NULL; EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); - EXPECT_EQ(input.initialization_time().InMilliseconds(), - output.initialization_time().InMilliseconds()); EXPECT_EQ(input.vendor_id(), output.vendor_id()); EXPECT_EQ(input.device_id(), output.device_id()); EXPECT_EQ(input.driver_version(), output.driver_version()); @@ -38,5 +35,5 @@ TEST(GPUIPCMessageTest, GPUInfo) { std::string log_message; IPC::LogParam(output, &log_message); - EXPECT_STREQ("<GPUInfo> 100 10de 429 6.14.11.7715 1", log_message.c_str()); + EXPECT_STREQ("<GPUInfo> 10de 429 6.14.11.7715 1", log_message.c_str()); } diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc index 51a75d5..0c0d3c51 100644 --- a/chrome/gpu/gpu_main.cc +++ b/chrome/gpu/gpu_main.cc @@ -2,23 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <stdlib.h> - -#include "app/gfx/gl/gl_context.h" #include "app/gfx/gl/gl_implementation.h" -#include "base/environment.h" #include "base/message_loop.h" -#include "base/metrics/field_trial.h" -#include "base/stringprintf.h" #include "build/build_config.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/env_vars.h" #include "chrome/common/main_function_params.h" #include "chrome/gpu/gpu_config.h" #include "chrome/gpu/gpu_process.h" #include "chrome/gpu/gpu_thread.h" -#include "chrome/gpu/gpu_watchdog_thread.h" #if defined(USE_LINUX_BREAKPAD) #include "chrome/app/breakpad_linux.h" @@ -33,17 +25,9 @@ #include "app/x11_util_internal.h" #endif - +#if defined(USE_X11) namespace { -// 1% per watchdog trial group. -const int kFieldTrialSize = 1; - -// 5 - 20 seconds timeout. -const int kMinGpuTimeout = 5; -const int kMaxGpuTimeout = 20; - -#if defined(USE_X11) int GpuX11ErrorHandler(Display* d, XErrorEvent* error) { LOG(ERROR) << x11_util::GetErrorEventDescription(d, error); return 0; @@ -53,14 +37,12 @@ void SetGpuX11ErrorHandlers() { // Set up the error handlers so that only general errors aren't fatal. x11_util::SetX11ErrorHandlers(GpuX11ErrorHandler, NULL); } -#endif } +#endif // Main function for starting the Gpu process. int GpuMain(const MainFunctionParams& parameters) { - base::Time start_time = base::Time::Now(); - #if defined(USE_LINUX_BREAKPAD) // Needs to be called after we have chrome::DIR_USER_DATA. InitCrashReporter(); @@ -83,75 +65,18 @@ int GpuMain(const MainFunctionParams& parameters) { #if defined(OS_WIN) win_util::ScopedCOMInitializer com_initializer; +#elif defined(GPU_USE_GLX) + gfx::InitializeGLBindings(gfx::kGLImplementationDesktopGL); #endif - // 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; - GpuProcess gpu_process; - GpuThread* gpu_thread = new GpuThread; - gpu_process.set_main_thread(gpu_thread); - - // Only enable this experimental feaure for a subset of users. - scoped_refptr<base::FieldTrial> watchdog_trial( - new base::FieldTrial("GpuWatchdogTrial", 100)); - int watchdog_timeout = 0; - for (int i = kMinGpuTimeout; i <= kMaxGpuTimeout; ++i) { - int group = watchdog_trial->AppendGroup(StringPrintf("%dsecs", i), - kFieldTrialSize); - if (group == watchdog_trial->group()) { - watchdog_timeout = i; - break; - } - } - - 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 - // to run slowly in that case. - bool enable_watchdog = - watchdog_timeout != 0 && - !command_line.HasSwitch(switches::kDisableGpuWatchdog) && - gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL && - !RunningOnValgrind(); - - // Disable the watchdog in debug builds because they tend to only be run by - // developers who will not appreciate the watchdog killing the GPU process. -#ifndef NDEBUG - enable_watchdog = false; -#endif - -// TODO(apatrick): Disable for this commit. I want to enable this feature with -// a simple single file change that can easily be reverted if need be without -// losing all the other features of the patch. -#if 1 - enable_watchdog = false; -#endif - - scoped_refptr<GpuWatchdogThread> watchdog_thread; - if (enable_watchdog) { - watchdog_thread = new GpuWatchdogThread(MessageLoop::current(), - watchdog_timeout * 1000); - watchdog_thread->Start(); - } + gpu_process.set_main_thread(new GpuThread()); #if defined(USE_X11) SetGpuX11ErrorHandlers(); #endif - // 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) - watchdog_thread->Stop(); - return 0; } diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index 3a1dc7b..8c1059f 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -12,6 +12,7 @@ #include "build/build_config.h" #include "chrome/common/child_process.h" #include "chrome/common/child_process_logging.h" +#include "chrome/common/gpu_info.h" #include "chrome/common/gpu_messages.h" #include "chrome/gpu/gpu_info_collector.h" #include "ipc/ipc_channel_handle.h" @@ -66,15 +67,6 @@ GpuThread::GpuThread() { GpuThread::~GpuThread() { } -void GpuThread::Init(const base::Time& process_start_time) { - gpu_info_collector::CollectGraphicsInfo(&gpu_info_); - child_process_logging::SetGpuInfo(gpu_info_); - - // Record initialization only after collecting the GPU info because that can - // take a significant amount of time. - gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time); -} - #if defined(GPU_USE_GLX) GpuBackingStoreGLXContext* GpuThread::GetGLXContext() { if (!glx_context_.get()) @@ -110,32 +102,40 @@ void GpuThread::OnEstablishChannel(int renderer_id) { IPC::ChannelHandle channel_handle; GPUInfo gpu_info; - GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); - if (iter == gpu_channels_.end()) { - channel = new GpuChannel(renderer_id); - } else { - channel = iter->second; - } - - DCHECK(channel != NULL); - - if (channel->Init()) { - gpu_channels_[renderer_id] = channel; - } else { - channel = NULL; - } - - if (channel.get()) { - channel_handle.name = channel->GetChannelName(); + // Fail to establish a channel if some implementation of GL cannot be + // initialized. + if (gfx::GLContext::InitializeOneOff()) { + // Fail to establish channel if GPU stats cannot be retreived. + if (gpu_info_collector::CollectGraphicsInfo(&gpu_info)) { + child_process_logging::SetGpuInfo(gpu_info); + GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); + if (iter == gpu_channels_.end()) { + channel = new GpuChannel(renderer_id); + } else { + channel = iter->second; + } + + DCHECK(channel != NULL); + + if (channel->Init()) { + gpu_channels_[renderer_id] = channel; + } else { + channel = NULL; + } + + if (channel.get()) { + channel_handle.name = channel->GetChannelName(); #if defined(OS_POSIX) - // On POSIX, pass the renderer-side FD. Also mark it as auto-close so - // that it gets closed after it has been sent. - int renderer_fd = channel->DisownRendererFd(); - channel_handle.socket = base::FileDescriptor(renderer_fd, true); + // On POSIX, pass the renderer-side FD. Also mark it as auto-close so + // that it gets closed after it has been sent. + int renderer_fd = channel->DisownRendererFd(); + channel_handle.socket = base::FileDescriptor(renderer_fd, true); #endif + } + } } - Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info_)); + Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info)); } void GpuThread::OnSynchronize() { @@ -157,7 +157,14 @@ void GpuThread::OnNewRenderWidgetHostView(GpuNativeWindowHandle parent_window, } void GpuThread::OnCollectGraphicsInfo() { - Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); + // Fail to establish a channel if some implementation of GL cannot be + // initialized. + GPUInfo gpu_info; + if (gfx::GLContext::InitializeOneOff()) { + gpu_info_collector::CollectGraphicsInfo(&gpu_info); + } + + Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info)); } void GpuThread::OnCrash() { diff --git a/chrome/gpu/gpu_thread.h b/chrome/gpu/gpu_thread.h index 6d20422..b896360 100644 --- a/chrome/gpu/gpu_thread.h +++ b/chrome/gpu/gpu_thread.h @@ -8,10 +8,8 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" -#include "base/time.h" #include "build/build_config.h" #include "chrome/common/child_thread.h" -#include "chrome/common/gpu_info.h" #include "chrome/common/gpu_native_window_handle.h" #include "chrome/gpu/gpu_channel.h" #include "chrome/gpu/gpu_config.h" @@ -27,8 +25,6 @@ class GpuThread : public ChildThread { GpuThread(); ~GpuThread(); - void Init(const base::Time& process_start_time); - #if defined(GPU_USE_GLX) GpuBackingStoreGLXContext* GetGLXContext(); @@ -59,9 +55,6 @@ class GpuThread : public ChildThread { scoped_ptr<GpuBackingStoreGLXContext> glx_context_; #endif - // Information about the GPU, such as device and vendor ID. - GPUInfo gpu_info_; - DISALLOW_COPY_AND_ASSIGN(GpuThread); }; diff --git a/chrome/gpu/gpu_watchdog_thread.cc b/chrome/gpu/gpu_watchdog_thread.cc deleted file mode 100644 index e262c79..0000000 --- a/chrome/gpu/gpu_watchdog_thread.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#if defined(OS_WIN) -#include <windows.h> -#endif - -#include "chrome/gpu/gpu_watchdog_thread.h" - -#include "base/compiler_specific.h" -#include "build/build_config.h" - -namespace { -const int64 kCheckPeriod = 2000; -} - -GpuWatchdogThread::GpuWatchdogThread(MessageLoop* watched_message_loop, - int timeout) - : base::Thread("Watchdog"), - watched_message_loop_(watched_message_loop), - timeout_(timeout) { - DCHECK(watched_message_loop); - DCHECK(timeout >= 0); -} - -GpuWatchdogThread::~GpuWatchdogThread() { - // Verify that the thread was explicitly stopped. If the thread is stopped - // implicitly by the destructor, CleanUp() will not be called. - DCHECK(!method_factory_.get()); -} - -void GpuWatchdogThread::Init() { - // The method factory must be created on the watchdog thread. - method_factory_.reset(new MethodFactory(this)); - - // Schedule the first check. - OnCheck(); -} - -void GpuWatchdogThread::CleanUp() { - // The method factory must be destroyed on the watchdog thread. - method_factory_->RevokeAll(); - method_factory_.reset(); - - // Prevent any more delayed tasks from being posted. - watched_message_loop_ = NULL; -} - -void GpuWatchdogThread::OnAcknowledge() { - // Revoke any pending OnExit. - method_factory_->RevokeAll(); - - // The monitored thread has responded. Post a task to check it again. - if (watched_message_loop_) { - message_loop()->PostDelayedTask( - FROM_HERE, - method_factory_->NewRunnableMethod(&GpuWatchdogThread::OnCheck), - kCheckPeriod); - } -} - -void GpuWatchdogThread::OnCheck() { - if (watched_message_loop_) { - // Post a task to the monitored thread that simply responds with a task that - // calls OnAcknowldge. - watched_message_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &GpuWatchdogThread::PostAcknowledge)); - - // Post a task to the watchdog thread to exit if the nmonitored thread does - // not respond in time. - message_loop()->PostDelayedTask( - FROM_HERE, - method_factory_->NewRunnableMethod(&GpuWatchdogThread::OnExit), - timeout_); - } -} - -void GpuWatchdogThread::PostAcknowledge() { - // Called on the monitored thread. Responds with OnAcknowledge. Cannot use - // the method factory. Rely on reference counting instead. - message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &GpuWatchdogThread::OnAcknowledge)); -} - -// Use the --disable-gpu-watchdog command line switch to disable this. -void GpuWatchdogThread::OnExit() { - // 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) - return; - -#if defined(OS_WIN) - if (IsDebuggerPresent()) - return; -#endif - - LOG(ERROR) << "The GPU process hung. Restarting after " - << timeout_ << " seconds."; - - volatile int* null_pointer = NULL; - *null_pointer = timeout; - - crashed = true; -} diff --git a/chrome/gpu/gpu_watchdog_thread.h b/chrome/gpu/gpu_watchdog_thread.h deleted file mode 100644 index d6e1117..0000000 --- a/chrome/gpu/gpu_watchdog_thread.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_GPU_GPU_WATCHDOG_THREAD_H_ -#define CHROME_GPU_GPU_WATCHDOG_THREAD_H_ - -#include "base/ref_counted.h" -#include "base/scoped_ptr.h" -#include "base/task.h" -#include "base/thread.h" - -// A thread that intermitently sends tasks to a group of watched message loops -// and deliberately crashes if one of them does not respond after a timeout. -class GpuWatchdogThread : public base::Thread, - public base::RefCountedThreadSafe<GpuWatchdogThread> { - public: - GpuWatchdogThread(MessageLoop* watched_message_loop, int timeout); - virtual ~GpuWatchdogThread(); - - protected: - virtual void Init(); - virtual void CleanUp(); - - private: - void OnAcknowledge(); - void OnCheck(); - void PostAcknowledge(); - void OnExit(); - void Disable(); - - MessageLoop* watched_message_loop_; - int timeout_; - - typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; - scoped_ptr<MethodFactory> method_factory_; - - DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); -}; - -#endif // CHROME_GPU_GPU_WATCHDOG_THREAD_H_ diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc index 43fe0c0..aade75f 100644 --- a/chrome/renderer/command_buffer_proxy.cc +++ b/chrome/renderer/command_buffer_proxy.cc @@ -53,6 +53,16 @@ void CommandBufferProxy::OnChannelError() { last_state_.error = gpu::error::kLostContext; } +bool CommandBufferProxy::Send(IPC::Message* msg) { + if (channel_) + return channel_->Send(msg); + + // Callee takes ownership of message, regardless of whether Send is + // successful. See IPC::Message::Sender. + delete msg; + return false; +} + bool CommandBufferProxy::Initialize(int32 size) { DCHECK(!ring_buffer_.get()); @@ -84,21 +94,14 @@ Buffer CommandBufferProxy::GetRingBuffer() { } gpu::CommandBuffer::State CommandBufferProxy::GetState() { - // Send will flag state with lost context if IPC fails. - if (last_state_.error == gpu::error::kNoError) - Send(new GpuCommandBufferMsg_GetState(route_id_, &last_state_)); - + Send(new GpuCommandBufferMsg_GetState(route_id_, &last_state_)); return last_state_; } gpu::CommandBuffer::State CommandBufferProxy::Flush(int32 put_offset) { - // Send will flag state with lost context if IPC fails. - if (last_state_.error == gpu::error::kNoError) { - Send(new GpuCommandBufferMsg_Flush(route_id_, - put_offset, - &last_state_)); - } - + Send(new GpuCommandBufferMsg_Flush(route_id_, + put_offset, + &last_state_)); return last_state_; } @@ -108,22 +111,14 @@ void CommandBufferProxy::SetGetOffset(int32 get_offset) { } int32 CommandBufferProxy::CreateTransferBuffer(size_t size) { - if (last_state_.error == gpu::error::kNoError) { - int32 id; - if (Send(new GpuCommandBufferMsg_CreateTransferBuffer(route_id_, - size, - &id))) { - return id; - } - } + int32 id; + if (Send(new GpuCommandBufferMsg_CreateTransferBuffer(route_id_, size, &id))) + return id; return -1; } void CommandBufferProxy::DestroyTransferBuffer(int32 id) { - if (last_state_.error != gpu::error::kNoError) - return; - // Remove the transfer buffer from the client side4 cache. TransferBufferMap::iterator it = transfer_buffers_.find(id); DCHECK(it != transfer_buffers_.end()); @@ -137,9 +132,6 @@ void CommandBufferProxy::DestroyTransferBuffer(int32 id) { } Buffer CommandBufferProxy::GetTransferBuffer(int32 id) { - if (last_state_.error != gpu::error::kNoError) - return Buffer(); - // Check local cache to see if there is already a client side shared memory // object for this id. TransferBufferMap::iterator it = transfer_buffers_.find(id); @@ -205,12 +197,8 @@ void CommandBufferProxy::SetSwapBuffersCallback(Callback0::Type* callback) { } void CommandBufferProxy::ResizeOffscreenFrameBuffer(const gfx::Size& size) { - if (last_state_.error != gpu::error::kNoError) - return; - IPC::Message* message = new GpuCommandBufferMsg_ResizeOffscreenFrameBuffer(route_id_, size); - // We need to set the unblock flag on this message to guarantee the // order in which it is processed in the GPU process. Ordinarily in // certain situations, namely if a synchronous message is being @@ -232,17 +220,11 @@ void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { #if defined(OS_MACOSX) void CommandBufferProxy::SetWindowSize(const gfx::Size& size) { - if (last_state_.error != gpu::error::kNoError) - return; - Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size)); } #endif void CommandBufferProxy::AsyncGetState(Task* completion_task) { - if (last_state_.error != gpu::error::kNoError) - return; - IPC::Message* message = new GpuCommandBufferMsg_AsyncGetState(route_id_); // Do not let a synchronous flush hold up this message. If this handler is @@ -255,9 +237,6 @@ void CommandBufferProxy::AsyncGetState(Task* completion_task) { } void CommandBufferProxy::AsyncFlush(int32 put_offset, Task* completion_task) { - if (last_state_.error != gpu::error::kNoError) - return; - IPC::Message* message = new GpuCommandBufferMsg_AsyncFlush(route_id_, put_offset); @@ -270,28 +249,6 @@ void CommandBufferProxy::AsyncFlush(int32 put_offset, Task* completion_task) { pending_async_flush_tasks_.push(linked_ptr<Task>(completion_task)); } -bool CommandBufferProxy::Send(IPC::Message* msg) { - // Caller should not intentionally send a message if the context is lost. - DCHECK(last_state_.error == gpu::error::kNoError); - - if (channel_) { - if (channel_->Send(msg)) { - return true; - } else { - // Flag the command buffer as lost. Defer deleting the channel until - // OnChannelError is called after returning to the message loop in case - // it is referenced elsewhere. - last_state_.error = gpu::error::kLostContext; - return false; - } - } - - // Callee takes ownership of message, regardless of whether Send is - // successful. See IPC::Message::Sender. - delete msg; - return false; -} - void CommandBufferProxy::OnUpdateState(gpu::CommandBuffer::State state) { last_state_ = state; diff --git a/chrome/renderer/command_buffer_proxy.h b/chrome/renderer/command_buffer_proxy.h index b425074..9b8e3f7 100644 --- a/chrome/renderer/command_buffer_proxy.h +++ b/chrome/renderer/command_buffer_proxy.h @@ -32,7 +32,8 @@ class Task; // Client side proxy that forwards messages synchronously to a // CommandBufferStub. class CommandBufferProxy : public gpu::CommandBuffer, - public IPC::Channel::Listener { + public IPC::Channel::Listener, + public IPC::Message::Sender { public: CommandBufferProxy(IPC::Channel::Sender* channel, int route_id); virtual ~CommandBufferProxy(); @@ -41,6 +42,9 @@ class CommandBufferProxy : public gpu::CommandBuffer, virtual void OnMessageReceived(const IPC::Message& message); virtual void OnChannelError(); + // IPC::Message::Sender implementation: + virtual bool Send(IPC::Message* msg); + int route_id() const { return route_id_; } // CommandBuffer implementation: @@ -85,12 +89,6 @@ class CommandBufferProxy : public gpu::CommandBuffer, void AsyncFlush(int32 put_offset, Task* completion_task); private: - - // Send an IPC message over the GPU channel. This is private to fully - // encapsulate the channel; all callers of this function must explicitly - // verify that the context has not been lost. - bool Send(IPC::Message* msg); - // Message handlers: void OnUpdateState(gpu::CommandBuffer::State state); void OnNotifyRepaint(); diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc index 2826013..0589852 100644 --- a/chrome/renderer/ggl/ggl.cc +++ b/chrome/renderer/ggl/ggl.cc @@ -156,7 +156,7 @@ bool Context::Initialize(gfx::NativeViewId view, const int32* attrib_list) { DCHECK(size.width() >= 0 && size.height() >= 0); - if (channel_->state() != GpuChannelHost::kConnected) + if (channel_->state() != GpuChannelHost::CONNECTED) return false; // Ensure the gles2 library is initialized first in a thread safe way. diff --git a/chrome/renderer/gpu_channel_host.cc b/chrome/renderer/gpu_channel_host.cc index 6ce8d7d..e2e14be 100644 --- a/chrome/renderer/gpu_channel_host.cc +++ b/chrome/renderer/gpu_channel_host.cc @@ -10,7 +10,7 @@ #include "chrome/renderer/command_buffer_proxy.h" #include "chrome/renderer/gpu_video_service_host.h" -GpuChannelHost::GpuChannelHost() : state_(kUnconnected) { +GpuChannelHost::GpuChannelHost() : state_(UNCONNECTED) { } GpuChannelHost::~GpuChannelHost() { @@ -26,7 +26,7 @@ void GpuChannelHost::Connect(const std::string& channel_name) { // It is safe to send IPC messages before the channel completes the connection // and receives the hello message from the GPU process. The messages get // cached. - state_ = kConnected; + state_ = CONNECTED; } void GpuChannelHost::set_gpu_info(const GPUInfo& gpu_info) { @@ -55,7 +55,7 @@ void GpuChannelHost::OnChannelConnected(int32 peer_pid) { } void GpuChannelHost::OnChannelError() { - state_ = kLost; + state_ = LOST; // Channel is invalid and will be reinitialized if this host is requested // again. @@ -76,13 +76,12 @@ void GpuChannelHost::OnChannelError() { } bool GpuChannelHost::Send(IPC::Message* message) { - if (channel_.get()) - return channel_->Send(message); + if (!channel_.get()) { + delete message; + return false; + } - // Callee takes ownership of message, regardless of whether Send is - // successful. See IPC::Message::Sender. - delete message; - return false; + return channel_->Send(message); } CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( diff --git a/chrome/renderer/gpu_channel_host.h b/chrome/renderer/gpu_channel_host.h index 818202e..dc738bd 100644 --- a/chrome/renderer/gpu_channel_host.h +++ b/chrome/renderer/gpu_channel_host.h @@ -30,12 +30,12 @@ class GpuChannelHost : public IPC::Channel::Listener, public: enum State { // Not yet connected. - kUnconnected, + UNCONNECTED, // Ready to use. - kConnected, + CONNECTED, // An error caused the host to become disconnected. Recreate channel to // reestablish connection. - kLost + LOST }; // Called on the render thread diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 3ab778d..ebb8af7 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -772,12 +772,12 @@ void RenderThread::EstablishGpuChannel() { if (gpu_channel_.get()) { // Do nothing if we already have a GPU channel or are already // establishing one. - if (gpu_channel_->state() == GpuChannelHost::kUnconnected || - gpu_channel_->state() == GpuChannelHost::kConnected) + if (gpu_channel_->state() == GpuChannelHost::UNCONNECTED || + gpu_channel_->state() == GpuChannelHost::CONNECTED) return; // Recreate the channel if it has been lost. - if (gpu_channel_->state() == GpuChannelHost::kLost) + if (gpu_channel_->state() == GpuChannelHost::LOST) gpu_channel_ = NULL; } @@ -798,7 +798,7 @@ GpuChannelHost* RenderThread::GetGpuChannel() { if (!gpu_channel_.get()) return NULL; - if (gpu_channel_->state() != GpuChannelHost::kConnected) + if (gpu_channel_->state() != GpuChannelHost::CONNECTED) return NULL; return gpu_channel_.get(); diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc index 3c4e38e..1ffd0fe 100644 --- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc +++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc @@ -70,7 +70,7 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); if (!host) return false; - DCHECK(host->state() == GpuChannelHost::kConnected); + DCHECK(host->state() == GpuChannelHost::CONNECTED); // Convert WebGL context creation attributes into GGL/EGL size requests. const int alpha_size = attributes.alpha ? 8 : 0; diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 69f2601..8c72435 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -12,7 +12,6 @@ #include <set> #include <vector> -#include "app/app_switches.h" #include "app/sql/connection.h" #include "base/base_switches.h" #include "base/command_line.h" @@ -136,9 +135,6 @@ void UITestBase::SetUp() { AssertAppNotRunning(L"Please close any other instances " L"of the app before testing."); - // Force all tests to use OSMesa if they launch the GPU process. - launch_arguments_.AppendSwitchASCII(switches::kUseGL, "osmesa"); - JavaScriptExecutionController::set_timeout( TestTimeouts::action_max_timeout_ms()); test_start_time_ = Time::NowFromSystemTime(); diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index cc10cc2..9664810 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -250,25 +250,6 @@ void ParamTraits<base::Time>::Log(const param_type& p, std::string* l) { ParamTraits<int64>::Log(p.ToInternalValue(), l); } -void ParamTraits<base::TimeDelta> ::Write(Message* m, const param_type& p) { - ParamTraits<int64> ::Write(m, p.InMicroseconds()); -} - -bool ParamTraits<base::TimeDelta> ::Read(const Message* m, - void** iter, - param_type* r) { - int64 value; - bool ret = ParamTraits<int64> ::Read(m, iter, &value); - if (ret) - *r = base::TimeDelta::FromMicroseconds(value); - - return ret; -} - -void ParamTraits<base::TimeDelta> ::Log(const param_type& p, std::string* l) { - ParamTraits<int64> ::Log(p.InMicroseconds(), l); -} - void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { WriteValue(m, &p, 0); } diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 9629fac..0e22c6b 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -88,7 +88,6 @@ class NullableString16; namespace base { class Time; -class TimeDelta; struct FileDescriptor; } @@ -294,14 +293,6 @@ struct ParamTraits<base::Time> { static void Log(const param_type& p, std::string* l); }; -template <> -struct ParamTraits<base::TimeDelta> { - typedef base::TimeDelta param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - #if defined(OS_WIN) template <> struct ParamTraits<LOGFONT> { |