Index: content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc |
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc |
index 6f2b3254df126073298e9ffcb4857f862f257a00..ac6ad870288fdb5e529709c6deb7b0953267b68e 100644 |
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc |
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc |
@@ -23,6 +23,7 @@ |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
#include "base/synchronization/lock.h" |
+#include "content/common/child_process.h" |
#include "content/public/common/content_switches.h" |
#include "content/renderer/gpu/command_buffer_proxy.h" |
#include "content/renderer/gpu/gpu_channel_host.h" |
@@ -147,6 +148,14 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); |
+ // If the context is being initialized on something other than the main |
+ // thread, then drop the web_view_ pointer so we don't accidentally |
+ // dereference it. |
+ MessageLoop* main_message_loop = |
+ ChildProcess::current()->main_thread()->message_loop(); |
+ if (MessageLoop::current() != main_message_loop) |
+ web_view_ = NULL; |
+ |
// Convert WebGL context creation attributes into RendererGLContext / EGL size |
// requests. |
const int alpha_size = attributes_.alpha ? 8 : 0; |