diff options
author | reveman <reveman@chromium.org> | 2015-06-26 14:47:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-26 21:48:17 +0000 |
commit | f6dffe4bd02803dd7cae455ff1a4c1ddb848e09f (patch) | |
tree | f7f49250b3d18512bf29ff7eaf9447a88322c611 | |
parent | 80201d111bd6f4221b70dd2cf101153e71945fca (diff) | |
download | chromium_src-f6dffe4bd02803dd7cae455ff1a4c1ddb848e09f.zip chromium_src-f6dffe4bd02803dd7cae455ff1a4c1ddb848e09f.tar.gz chromium_src-f6dffe4bd02803dd7cae455ff1a4c1ddb848e09f.tar.bz2 |
content: Set IOSurface manager token in the Gpu process before handling GpuMemoryBuffer allocation requests.
This makes sure we send and process a valid IOSurface manager token
on the Gpu process side before we handle any GpuMemoryBuffer allocation
requests.
BUG=486922
TEST=content/test/gpu/run_gpu_test.py context_lost --extra-browser-args=--enable-native-gpu-memory-buffers --story-filter=GpuCrash.GPUProcessCrashesExactlyOnce
Review URL: https://codereview.chromium.org/1207043003
Cr-Commit-Position: refs/heads/master@{#336461}
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 21 | ||||
-rw-r--r-- | content/child/child_thread_impl.cc | 38 | ||||
-rw-r--r-- | content/child/child_thread_impl.h | 7 |
3 files changed, 42 insertions, 24 deletions
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index c6aec18..6fff587 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -551,6 +551,14 @@ bool GpuProcessHost::Init() { if (!Send(new GpuMsg_Initialize())) return false; +#if defined(OS_MACOSX) && !defined(OS_IOS) + io_surface_manager_token_ = + BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken(); + // Note: A valid IOSurface manager token needs to be sent to the Gpu process + // before any GpuMemoryBuffer allocation requests can be sent. + Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_)); +#endif + return true; } @@ -617,12 +625,6 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { void GpuProcessHost::OnChannelConnected(int32 peer_pid) { TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); -#if defined(OS_MACOSX) && !defined(OS_IOS) - io_surface_manager_token_ = - BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken(); - Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_)); -#endif - while (!queued_messages_.empty()) { Send(queued_messages_.front()); queued_messages_.pop(); @@ -888,6 +890,13 @@ void GpuProcessHost::ForceShutdown() { if (g_gpu_process_hosts[kind_] == this) g_gpu_process_hosts[kind_] = NULL; +#if defined(OS_MACOSX) && !defined(OS_IOS) + if (!io_surface_manager_token_.IsZero()) { + BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); + io_surface_manager_token_.SetZero(); + } +#endif + process_->ForceShutdown(); } diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index 04e020c..45d8cdb 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc @@ -175,6 +175,29 @@ class SuicideOnChannelErrorFilter : public IPC::MessageFilter { #endif // OS(POSIX) +#if defined(OS_MACOSX) +class IOSurfaceManagerFilter : public IPC::MessageFilter { + public: + // Overridden from IPC::MessageFilter: + bool OnMessageReceived(const IPC::Message& message) override { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(IOSurfaceManagerFilter, message) + IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIOSurfaceManagerToken, + OnSetIOSurfaceManagerToken) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; + } + + protected: + ~IOSurfaceManagerFilter() override {} + + void OnSetIOSurfaceManagerToken(const IOSurfaceManagerToken& token) { + ChildIOSurfaceManager::GetInstance()->set_token(token); + } +}; +#endif + #if defined(OS_ANDROID) // A class that allows for triggering a clean shutdown from another // thread through draining the main thread's msg loop. @@ -415,6 +438,10 @@ void ChildThreadImpl::Init(const Options& options) { channel_->AddFilter(new SuicideOnChannelErrorFilter()); #endif +#if defined(OS_MACOSX) + channel_->AddFilter(new IOSurfaceManagerFilter()); +#endif + // Add filters passed here via options. for (auto startup_filter : options.startup_filters) { channel_->AddFilter(startup_filter); @@ -596,10 +623,6 @@ bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { #if defined(USE_TCMALLOC) IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) #endif -#if defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIOSurfaceManagerToken, - OnSetIOSurfaceManagerToken) -#endif IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -656,13 +679,6 @@ void ChildThreadImpl::OnGetTcmallocStats() { } #endif -#if defined(OS_MACOSX) -void ChildThreadImpl::OnSetIOSurfaceManagerToken( - const IOSurfaceManagerToken& token) { - ChildIOSurfaceManager::GetInstance()->set_token(token); -} -#endif - ChildThreadImpl* ChildThreadImpl::current() { return g_lazy_tls.Pointer()->Get(); } diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h index d124a50..3a18237 100644 --- a/content/child/child_thread_impl.h +++ b/content/child/child_thread_impl.h @@ -20,10 +20,6 @@ #include "content/public/child/child_thread.h" #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. -#if defined(OS_MACOSX) && !defined(OS_IOS) -#include "content/common/mac/io_surface_manager_token.h" -#endif - namespace base { class MessageLoop; @@ -238,9 +234,6 @@ class CONTENT_EXPORT ChildThreadImpl #if defined(USE_TCMALLOC) void OnGetTcmallocStats(); #endif -#if defined(OS_MACOSX) && !defined(OS_IOS) - void OnSetIOSurfaceManagerToken(const IOSurfaceManagerToken& token); -#endif void EnsureConnected(); |