summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-07 00:39:14 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-07 00:39:14 +0000
commit3c3e9cbd14db0b8cfb0c26d3ecf82fbd99e636d0 (patch)
tree7065896c271545b4fefbd2020226a069a4b89d9b /content
parent9a811701c538c6439d9a800fae303d46300f7db5 (diff)
downloadchromium_src-3c3e9cbd14db0b8cfb0c26d3ecf82fbd99e636d0.zip
chromium_src-3c3e9cbd14db0b8cfb0c26d3ecf82fbd99e636d0.tar.gz
chromium_src-3c3e9cbd14db0b8cfb0c26d3ecf82fbd99e636d0.tar.bz2
Merge 120651 - Reduce GPU sandbox level on NVIDIA optimus computers.
We've noticed a higher crash rate on computers that are using NVIDIA optimus since the most restrictive GPU process sandboxing was added, so add code to detect them and reduce the sandboxing back to M17 levels. BUG=110552 TEST= Review URL: https://chromiumcodereview.appspot.com/9334009 TBR=jbauman@chromium.org Review URL: https://chromiumcodereview.appspot.com/9351002 git-svn-id: svn://svn.chromium.org/chrome/branches/1025/src@120657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/gpu/gpu_data_manager.cc6
-rw-r--r--content/browser/gpu/gpu_process_host.cc1
-rw-r--r--content/common/gpu/gpu_messages.h1
-rw-r--r--content/common/sandbox_policy.cc3
-rw-r--r--content/gpu/gpu_info_collector_win.cc6
-rw-r--r--content/public/common/content_switches.cc3
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--content/public/common/gpu_info.cc3
-rw-r--r--content/public/common/gpu_info.h5
9 files changed, 25 insertions, 4 deletions
diff --git a/content/browser/gpu/gpu_data_manager.cc b/content/browser/gpu/gpu_data_manager.cc
index 64bc184..d02569b 100644
--- a/content/browser/gpu/gpu_data_manager.cc
+++ b/content/browser/gpu/gpu_data_manager.cc
@@ -504,6 +504,9 @@ void GpuDataManager::AppendGpuCommandLine(
} else if (!user_flags_.use_gl().empty()) {
command_line->AppendSwitchASCII(switches::kUseGL, user_flags_.use_gl());
}
+
+ if (gpu_info().optimus)
+ command_line->AppendSwitch(switches::kReduceGpuSandbox);
}
void GpuDataManager::SetGpuBlacklist(GpuBlacklist* gpu_blacklist) {
@@ -535,6 +538,8 @@ DictionaryValue* GpuDataManager::GpuInfoAsDictionaryValue() const {
"Vendor Id", base::StringPrintf("0x%04x", gpu_info().vendor_id)));
basic_info->Append(NewDescriptionValuePair(
"Device Id", base::StringPrintf("0x%04x", gpu_info().device_id)));
+ basic_info->Append(NewDescriptionValuePair(
+ "Optimus", Value::CreateBooleanValue(gpu_info().optimus)));
basic_info->Append(NewDescriptionValuePair("Driver vendor",
gpu_info().driver_vendor));
basic_info->Append(NewDescriptionValuePair("Driver version",
@@ -722,6 +727,7 @@ bool GpuDataManager::Merge(content::GPUInfo* object,
if (!object->finalized) {
object->finalized = other.finalized;
object->initialization_time = other.initialization_time;
+ object->optimus |= other.optimus;
if (object->driver_vendor.empty()) {
changed |= object->driver_vendor != other.driver_vendor;
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 08c7086..a58ad19 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -568,6 +568,7 @@ bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) {
switches::kDisableGLMultisampling,
switches::kDisableGpuDriverBugWorkarounds,
switches::kDisableGpuSandbox,
+ switches::kReduceGpuSandbox,
switches::kDisableGpuVsync,
switches::kDisableGpuWatchdog,
switches::kDisableImageTransportSurface,
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index f41437b..6dfb901 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -91,6 +91,7 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::GPUInfo)
IPC_STRUCT_TRAITS_MEMBER(finalized)
IPC_STRUCT_TRAITS_MEMBER(initialization_time)
+ IPC_STRUCT_TRAITS_MEMBER(optimus)
IPC_STRUCT_TRAITS_MEMBER(vendor_id)
IPC_STRUCT_TRAITS_MEMBER(device_id)
IPC_STRUCT_TRAITS_MEMBER(driver_vendor)
diff --git a/content/common/sandbox_policy.cc b/content/common/sandbox_policy.cc
index 31c6854..b4690af 100644
--- a/content/common/sandbox_policy.cc
+++ b/content/common/sandbox_policy.cc
@@ -316,7 +316,8 @@ bool AddPolicyForGPU(CommandLine* cmd_line, sandbox::TargetPolicy* policy) {
policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
} else {
if (cmd_line->GetSwitchValueASCII(switches::kUseGL) ==
- gfx::kGLImplementationSwiftShaderName) {
+ gfx::kGLImplementationSwiftShaderName ||
+ cmd_line->HasSwitch(switches::kReduceGpuSandbox)) {
policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
sandbox::USER_LIMITED);
} else {
diff --git a/content/gpu/gpu_info_collector_win.cc b/content/gpu/gpu_info_collector_win.cc
index aa902c5..1736f43 100644
--- a/content/gpu/gpu_info_collector_win.cc
+++ b/content/gpu/gpu_info_collector_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -154,6 +154,10 @@ bool CollectGraphicsInfoD3D(IDirect3D9* d3d, content::GPUInfo* gpu_info) {
bool CollectVideoCardInfo(content::GPUInfo* gpu_info) {
DCHECK(gpu_info);
+ // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled.
+ HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll");
+ gpu_info->optimus = nvd3d9wrap != NULL;
+
// Taken from http://developer.nvidia.com/object/device_ids.html
DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 6ddd375..9d20c2c 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -112,6 +112,9 @@ const char kDisableGpuDriverBugWorkarounds[] =
// Disable the GPU process sandbox.
const char kDisableGpuSandbox[] = "disable-gpu-sandbox";
+// Reduces the GPU process sandbox to be less strict.
+const char kReduceGpuSandbox[] = "reduce-gpu-sandbox";
+
// 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/content/public/common/content_switches.h b/content/public/common/content_switches.h
index ba48bfe..90e1082 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -46,6 +46,7 @@ CONTENT_EXPORT extern const char kDisableGLMultisampling[];
extern const char kDisableGLSLTranslator[];
extern const char kDisableGpuDriverBugWorkarounds[];
extern const char kDisableGpuSandbox[];
+extern const char kReduceGpuSandbox[];
extern const char kDisableGpuWatchdog[];
CONTENT_EXPORT extern const char kDisableHangMonitor[];
extern const char kDisableImageTransportSurface[];
diff --git a/content/public/common/gpu_info.cc b/content/public/common/gpu_info.cc
index c1c996b..b4e17f6 100644
--- a/content/public/common/gpu_info.cc
+++ b/content/public/common/gpu_info.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -8,6 +8,7 @@ namespace content {
GPUInfo::GPUInfo()
: finalized(false),
+ optimus(false),
vendor_id(0),
device_id(0),
can_lose_context(false) {
diff --git a/content/public/common/gpu_info.h b/content/public/common/gpu_info.h
index 9fd0d76..cf4b8dc 100644
--- a/content/public/common/gpu_info.h
+++ b/content/public/common/gpu_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -30,6 +30,9 @@ struct CONTENT_EXPORT GPUInfo {
// loop being pumped.
base::TimeDelta initialization_time;
+ // Computer has NVIDIA Optimus
+ bool optimus;
+
// The DWORD (uint32) representing the graphics card vendor id.
uint32 vendor_id;