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

Unified Diff: content/gpu/gpu_main.cc

Issue 1542013005: Add a new driver bug workaround SANDBOX_START_EARLY Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some draft code to discuss about generalizing EarlySandbox for gpu process 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
Index: content/gpu/gpu_main.cc
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
index 7cfe9187ffcd038c57a17c9ef7e1ed41c190f086..84ff0060f2907b792fd553fb22732f6850b8ae98 100644
--- a/content/gpu/gpu_main.cc
+++ b/content/gpu/gpu_main.cc
@@ -15,6 +15,7 @@
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
+#include "base/sys_info.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
@@ -43,6 +44,10 @@
#include "ui/gl/gl_switches.h"
#include "ui/gl/gpu_switching_manager.h"
+#if defined(OS_POSIX)
+#include <dlfcn.h>
+#endif
+
#if defined(OS_WIN)
#include <dwmapi.h>
#include <windows.h>
@@ -481,6 +486,29 @@ bool WarmUpSandbox(const base::CommandLine& command_line) {
#if defined(OS_WIN)
media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
#endif
+
+#if defined(OS_LINUX)
+ if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) {
+ // XXX: move all above code to the new GpuProcessPolicyEarlySandbox.
+
+ // uname is used from GpuControlList when calling
+ // gpu::ApplyGpuDriverBugWorkarounds.
+ base::SysInfo::OperatingSystemVersion();
+
+ // Cannot use base::LoadNativeLibrary because it uses RTLD_LAZY.
+ // We want to avoid the situation where a required symbol is loaded
+ // after the sandbox is ON. So load all symbols now.
+ // XXX: Instead of the library name above, uses:
+ // ui/gl/gl_implementation_x11.cc::kGLLibraryName, kGLESv2LibraryName, ...
+ dlopen("libglapi.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
+ dlopen("libGL.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
+
+ // XXX: find a way to determine when we know we are going to use llvmpipe
+ // driver.
+ dlopen("dri/swrast_dri.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
Ken Russell (switch to Gerrit) 2016/05/04 20:36:17 Yes, this is not acceptable to commit in its curre
+ }
+#endif
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698