diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-17 20:27:28 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-17 20:27:28 +0000 |
commit | 085170ca05a3660eaefcb16f4d79fad33583fe5a (patch) | |
tree | ebffd14c8b08179beaf1166f93a29a5f8bf54c24 | |
parent | e6c142173ba9ee4f532f7a470e8c57959af83007 (diff) | |
download | chromium_src-085170ca05a3660eaefcb16f4d79fad33583fe5a.zip chromium_src-085170ca05a3660eaefcb16f4d79fad33583fe5a.tar.gz chromium_src-085170ca05a3660eaefcb16f4d79fad33583fe5a.tar.bz2 |
Disable GPU info collection on GPU process startup on Win/Mac.
This is because preliminary GPU info is enough for making final blacklist decisions on Win/Mac.
However, at the moment on Linux, blacklist decisions are still depending on full GPU info in certain cases, so we still need to do it on Linux.
The full GPU info collection is done on demand when about:gpu page opens.
Also, we need GPU's vendor_id, device_id, driver_version for crash reporting in GPU process. So before about:gpu page opens, we won't have them. Therefore, we pass them down from browser process to GPU process through commandline switches.
BUG=128082
TEST=about:gpu
R=apatrick
TBR=jam
Review URL: https://chromiumcodereview.appspot.com/10310180
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137725 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/gpu/gpu_data_manager_impl.cc | 9 | ||||
-rw-r--r-- | content/gpu/gpu_child_thread.cc | 36 | ||||
-rw-r--r-- | content/gpu/gpu_main.cc | 40 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 9 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 3 |
5 files changed, 70 insertions, 27 deletions
diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc index 8e88dc7..076cec6 100644 --- a/content/browser/gpu/gpu_data_manager_impl.cc +++ b/content/browser/gpu/gpu_data_manager_impl.cc @@ -215,6 +215,15 @@ void GpuDataManagerImpl::AppendGpuCommandLine( command_line->AppendSwitch(switches::kReduceGpuSandbox); command_line->AppendSwitch(switches::kDisableImageTransportSurface); } + // Pass GPU and driver information to GPU process. We try to avoid full GPU + // info collection at GPU process startup, but we need gpu vendor_id, + // device_id, driver_version for crash reporting purpose. + command_line->AppendSwitchASCII(switches::kGpuVendorID, + base::StringPrintf("0x%04x", gpu_info_.gpu.vendor_id)); + command_line->AppendSwitchASCII(switches::kGpuDeviceID, + base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); + command_line->AppendSwitchASCII(switches::kGpuDriverVersion, + gpu_info_.driver_version); } } diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index 7735275..2fd64c2 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc @@ -15,6 +15,7 @@ #include "content/common/gpu/gpu_messages.h" #include "content/gpu/gpu_info_collector.h" #include "content/gpu/gpu_watchdog_thread.h" +#include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_sync_message_filter.h" @@ -64,9 +65,6 @@ GpuChildThread::GpuChildThread(const std::string& channel_id) target_services_ = NULL; collecting_dx_diagnostics_ = false; #endif - if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info_)) { - LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo failed"; - } } @@ -107,7 +105,7 @@ bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { void GpuChildThread::OnInitialize() { if (dead_on_arrival_) { - LOG(INFO) << "Exiting GPU process due to errors during initialization"; + VLOG(1) << "Exiting GPU process due to errors during initialization"; MessageLoop::current()->Quit(); return; } @@ -163,9 +161,11 @@ void GpuChildThread::OnInitialize() { ChildProcess::current()->io_message_loop_proxy(), ChildProcess::current()->GetShutDownEvent())); +#if defined(OS_LINUX) // Ensure the browser process receives the GPU info before a reply to any // subsequent IPC it might send. Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); +#endif } void GpuChildThread::StopWatchdog() { @@ -175,13 +175,20 @@ void GpuChildThread::StopWatchdog() { } void GpuChildThread::OnCollectGraphicsInfo() { + if (!gpu_info_.finalized && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableGpuSandbox)) { + // GPU full info collection should only happen on un-sandboxed GPU process. + + if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info_)) + VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; + content::GetContentClient()->SetGpuInfo(gpu_info_); + #if defined(OS_WIN) - if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { - // Prevent concurrent collection of DirectX diagnostics. - collecting_dx_diagnostics_ = true; + if (!collecting_dx_diagnostics_) { + // Prevent concurrent collection of DirectX diagnostics. + collecting_dx_diagnostics_ = true; - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableGpuSandbox)) { // Asynchronously collect the DirectX diagnostics because this can take a // couple of seconds. if (!base::WorkerPool::PostTask( @@ -191,31 +198,28 @@ void GpuChildThread::OnCollectGraphicsInfo() { // collected. collecting_dx_diagnostics_ = false; gpu_info_.finalized = true; - } else { - // Do not send response if we are still completing the GPUInfo struct - return; } } - } #endif + } Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); } void GpuChildThread::OnClean() { - LOG(INFO) << "GPU: Removing all contexts"; + VLOG(1) << "GPU: Removing all contexts"; if (gpu_channel_manager_.get()) gpu_channel_manager_->LoseAllContexts(); } void GpuChildThread::OnCrash() { - LOG(INFO) << "GPU: Simulating GPU crash"; + VLOG(1) << "GPU: Simulating GPU crash"; // Good bye, cruel world. volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; *it_s_the_end_of_the_world_as_we_know_it = 0xdead; } void GpuChildThread::OnHang() { - LOG(INFO) << "GPU: Simulating GPU hang"; + VLOG(1) << "GPU: Simulating GPU hang"; for (;;) { // Do not sleep here. The GPU watchdog timer tracks the amount of user // time this thread is using and it doesn't use much while calling Sleep. diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc index c3882e1..f2bf4ad 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -11,6 +11,7 @@ #include "base/environment.h" #include "base/message_loop.h" #include "base/rand_util.h" +#include "base/string_number_conversions.h" #include "base/stringprintf.h" #include "base/threading/platform_thread.h" #include "base/win/scoped_com_initializer.h" @@ -72,31 +73,48 @@ int GpuMain(const content::MainFunctionParams& parameters) { // GpuMsg_Initialize message from the browser. bool dead_on_arrival = false; - // Load and initialize the GL implementation and locate the GL entry points. content::GPUInfo gpu_info; - if (gfx::GLSurface::InitializeOneOff()) { - // Collect information about the GPU. - if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) { - LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo failed"; - } + // Get vendor_id, device_id, driver_version from browser process through + // commandline switches. + DCHECK(command_line.HasSwitch(switches::kGpuVendorID) && + command_line.HasSwitch(switches::kGpuDeviceID) && + command_line.HasSwitch(switches::kGpuDriverVersion)); + bool success = base::HexStringToInt( + command_line.GetSwitchValueASCII(switches::kGpuVendorID), + reinterpret_cast<int*>(&(gpu_info.gpu.vendor_id))); + DCHECK(success); + success = base::HexStringToInt( + command_line.GetSwitchValueASCII(switches::kGpuDeviceID), + reinterpret_cast<int*>(&(gpu_info.gpu.device_id))); + gpu_info.driver_version = + command_line.GetSwitchValueASCII(switches::kGpuDriverVersion); + content::GetContentClient()->SetGpuInfo(gpu_info); + // Load and initialize the GL implementation and locate the GL entry points. + if (gfx::GLSurface::InitializeOneOff()) { #if defined(OS_LINUX) + // We collect full GPU info on demand in Win/Mac, i.e., when about:gpu + // page opens. This is because we can make blacklist decisions based on + // preliminary GPU info. + // However, on Linux, blacklist decisions are based on full GPU info. + if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) + VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; + content::GetContentClient()->SetGpuInfo(gpu_info); + if (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA gpu_info.driver_vendor == "NVIDIA") { base::ThreadRestrictions::AssertIOAllowed(); if (access("/dev/nvidiactl", R_OK) != 0) { - LOG(INFO) << "NVIDIA device file /dev/nvidiactl access denied"; + VLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; gpu_info.gpu_accessible = false; dead_on_arrival = true; } } #endif - - // Set the GPU info even if it failed. - content::GetContentClient()->SetGpuInfo(gpu_info); } else { - LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed"; + VLOG(1) << "gfx::GLSurface::InitializeOneOff failed"; gpu_info.gpu_accessible = false; + gpu_info.finalized = true; dead_on_arrival = true; } diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index a76a3b1..e00e557 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -368,6 +368,12 @@ const char kForceFieldTrials[] = "force-fieldtrials"; // overrides this if present. const char kForceRendererAccessibility[] = "force-renderer-accessibility"; +// Passes gpu device_id from browser process to GPU process. +const char kGpuDeviceID[] = "gpu-device-id"; + +// Passes gpu driver_version from browser process to GPU process. +const char kGpuDriverVersion[] = "gpu-driver-version"; + // Extra command line options for launching the GPU process (normally used // for debugging). Use like renderer-cmd-prefix. const char kGpuLauncher[] = "gpu-launcher"; @@ -378,6 +384,9 @@ const char kGpuProcess[] = "gpu-process"; // Causes the GPU process to display a dialog on launch. const char kGpuStartupDialog[] = "gpu-startup-dialog"; +// Passes gpu vendor_id from browser process to GPU process. +const char kGpuVendorID[] = "gpu-vendor-id"; + // Run the GPU process as a thread in the browser process. const char kInProcessGPU[] = "in-process-gpu"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 3c91f209..4a94a71 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -115,9 +115,12 @@ extern const char kExtraPluginDir[]; CONTENT_EXPORT extern const char kForceCompositingMode[]; extern const char kForceFieldTrials[]; CONTENT_EXPORT extern const char kForceRendererAccessibility[]; +extern const char kGpuDeviceID[]; +extern const char kGpuDriverVersion[]; extern const char kGpuLauncher[]; CONTENT_EXPORT extern const char kGpuProcess[]; extern const char kGpuStartupDialog[]; +extern const char kGpuVendorID[]; extern const char kInProcessGPU[]; extern const char kInProcessPlugins[]; CONTENT_EXPORT extern const char kInProcessWebGL[]; |