[email protected] | f091824 | 2012-02-18 00:30:50 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c0fc094 | 2010-01-13 00:55:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 5 | #include "content/gpu/gpu_child_thread.h" |
[email protected] | c0fc094 | 2010-01-13 00:55:37 | [diff] [blame] | 6 | |
[email protected] | 8075105 | 2011-11-12 17:10:58 | [diff] [blame] | 7 | #include "base/bind.h" |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 8 | #include "base/lazy_instance.h" |
[email protected] | ac9ba8fe | 2010-12-30 18:08:36 | [diff] [blame] | 9 | #include "base/threading/worker_pool.h" |
[email protected] | 274aa588 | 2010-07-15 21:12:23 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | 10208ea | 2013-06-06 20:08:03 | [diff] [blame] | 11 | #include "content/child/child_process.h" |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 12 | #include "content/child/thread_safe_sender.h" |
[email protected] | 202b54ff | 2011-04-22 21:36:38 | [diff] [blame] | 13 | #include "content/common/gpu/gpu_messages.h" |
[email protected] | 623c0bd | 2011-03-12 01:00:41 | [diff] [blame] | 14 | #include "content/gpu/gpu_watchdog_thread.h" |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 15 | #include "content/public/common/content_client.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 16 | #include "content/public/common/content_switches.h" |
[email protected] | d7b5cc7 | 2013-05-23 20:05:00 | [diff] [blame] | 17 | #include "gpu/config/gpu_info_collector.h" |
[email protected] | 939856a | 2010-08-24 20:29:02 | [diff] [blame] | 18 | #include "ipc/ipc_channel_handle.h" |
[email protected] | 8c81e9ecc | 2012-04-25 00:42:27 | [diff] [blame] | 19 | #include "ipc/ipc_sync_message_filter.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 20 | #include "ui/gl/gl_implementation.h" |
[email protected] | 7709e71 | 2011-01-07 17:57:31 | [diff] [blame] | 21 | |
[email protected] | 929881f | 2014-06-20 21:00:36 | [diff] [blame] | 22 | #if defined(USE_OZONE) |
[email protected] | 929881f | 2014-06-20 21:00:36 | [diff] [blame] | 23 | #include "ui/ozone/public/gpu_platform_support.h" |
[email protected] | f88a8f7 | 2014-07-11 18:07:49 | [diff] [blame] | 24 | #include "ui/ozone/public/ozone_platform.h" |
[email protected] | 929881f | 2014-06-20 21:00:36 | [diff] [blame] | 25 | #endif |
| 26 | |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 27 | namespace content { |
[email protected] | 7709e71 | 2011-01-07 17:57:31 | [diff] [blame] | 28 | namespace { |
| 29 | |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 30 | static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
| 31 | g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
| 32 | |
[email protected] | 9158f2f | 2011-01-27 21:08:57 | [diff] [blame] | 33 | bool GpuProcessLogMessageHandler(int severity, |
| 34 | const char* file, int line, |
| 35 | size_t message_start, |
| 36 | const std::string& str) { |
[email protected] | e6ff5a3 | 2011-01-31 20:36:22 | [diff] [blame] | 37 | std::string header = str.substr(0, message_start); |
[email protected] | 9158f2f | 2011-01-27 21:08:57 | [diff] [blame] | 38 | std::string message = str.substr(message_start); |
[email protected] | 8c81e9ecc | 2012-04-25 00:42:27 | [diff] [blame] | 39 | |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 40 | g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage( |
| 41 | severity, header, message)); |
[email protected] | 8c81e9ecc | 2012-04-25 00:42:27 | [diff] [blame] | 42 | |
[email protected] | 9158f2f | 2011-01-27 21:08:57 | [diff] [blame] | 43 | return false; |
| 44 | } |
| 45 | |
[email protected] | e6ff5a3 | 2011-01-31 20:36:22 | [diff] [blame] | 46 | } // namespace |
[email protected] | 9158f2f | 2011-01-27 21:08:57 | [diff] [blame] | 47 | |
[email protected] | db6101db | 2012-10-25 15:20:08 | [diff] [blame] | 48 | GpuChildThread::GpuChildThread(GpuWatchdogThread* watchdog_thread, |
| 49 | bool dead_on_arrival, |
[email protected] | ec4bda6 | 2013-06-14 15:51:03 | [diff] [blame] | 50 | const gpu::GPUInfo& gpu_info, |
| 51 | const DeferredMessages& deferred_messages) |
[email protected] | f091824 | 2012-02-18 00:30:50 | [diff] [blame] | 52 | : dead_on_arrival_(dead_on_arrival), |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 53 | gpu_info_(gpu_info), |
[email protected] | ec4bda6 | 2013-06-14 15:51:03 | [diff] [blame] | 54 | deferred_messages_(deferred_messages), |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 55 | in_browser_process_(false) { |
[email protected] | db6101db | 2012-10-25 15:20:08 | [diff] [blame] | 56 | watchdog_thread_ = watchdog_thread; |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 57 | #if defined(OS_WIN) |
[email protected] | 5abe630 | 2011-12-20 23:44:32 | [diff] [blame] | 58 | target_services_ = NULL; |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 59 | #endif |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 60 | g_thread_safe_sender.Get() = thread_safe_sender(); |
[email protected] | 0b2cec6 | 2011-07-22 18:13:28 | [diff] [blame] | 61 | } |
[email protected] | 9158f2f | 2011-01-27 21:08:57 | [diff] [blame] | 62 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 63 | GpuChildThread::GpuChildThread(const std::string& channel_id) |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 64 | : ChildThread(Options(channel_id, false)), |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 65 | dead_on_arrival_(false), |
| 66 | in_browser_process_(true) { |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 67 | #if defined(OS_WIN) |
| 68 | target_services_ = NULL; |
| 69 | #endif |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 70 | DCHECK( |
[email protected] | 2d3de545 | 2013-01-18 10:03:40 | [diff] [blame] | 71 | CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 72 | CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)); |
[email protected] | af7c5d9 | 2014-02-03 19:53:15 | [diff] [blame] | 73 | #if !defined(OS_ANDROID) |
[email protected] | 50749e0 | 2013-03-08 04:56:53 | [diff] [blame] | 74 | // For single process and in-process GPU mode, we need to load and |
| 75 | // initialize the GL implementation and locate the GL entry points here. |
[email protected] | af7c5d9 | 2014-02-03 19:53:15 | [diff] [blame] | 76 | // On Android, GLSurface::InitializeOneOff() is called from BrowserMainLoop |
| 77 | // before getting here. crbug.com/326295 |
| 78 | if (!gfx::GLSurface::InitializeOneOff()) |
| 79 | VLOG(1) << "gfx::GLSurface::InitializeOneOff failed"; |
| 80 | #endif |
[email protected] | ca405d2 | 2013-06-25 23:28:55 | [diff] [blame] | 81 | g_thread_safe_sender.Get() = thread_safe_sender(); |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 82 | } |
| 83 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 84 | GpuChildThread::~GpuChildThread() { |
[email protected] | ce79d851 | 2013-04-22 22:44:41 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | void GpuChildThread::Shutdown() { |
[email protected] | 0e7015f | 2013-07-23 21:51:11 | [diff] [blame] | 88 | ChildThread::Shutdown(); |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 89 | logging::SetLogMessageHandler(NULL); |
| 90 | } |
| 91 | |
| 92 | void GpuChildThread::Init(const base::Time& process_start_time) { |
| 93 | process_start_time_ = process_start_time; |
| 94 | } |
| 95 | |
| 96 | bool GpuChildThread::Send(IPC::Message* msg) { |
| 97 | // The GPU process must never send a synchronous IPC message to the browser |
[email protected] | 4c0e289d | 2011-06-01 03:45:51 | [diff] [blame] | 98 | // process. This could result in deadlock. |
| 99 | DCHECK(!msg->is_sync()); |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 100 | |
| 101 | return ChildThread::Send(msg); |
| 102 | } |
| 103 | |
| 104 | bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 105 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 106 | IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 107 | IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize) |
| 108 | IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) |
[email protected] | fb246af | 2012-08-18 03:11:41 | [diff] [blame] | 109 | IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, |
| 110 | OnGetVideoMemoryUsageStats) |
[email protected] | 184e3f380 | 2011-05-04 20:48:52 | [diff] [blame] | 111 | IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 112 | IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) |
| 113 | IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) |
[email protected] | 31583a9d | 2012-11-30 00:37:17 | [diff] [blame] | 114 | IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 115 | IPC_MESSAGE_UNHANDLED(handled = false) |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 116 | IPC_END_MESSAGE_MAP() |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 117 | |
| 118 | if (handled) |
| 119 | return true; |
| 120 | |
[email protected] | 929881f | 2014-06-20 21:00:36 | [diff] [blame] | 121 | #if defined(USE_OZONE) |
| 122 | if (ui::OzonePlatform::GetInstance() |
| 123 | ->GetGpuPlatformSupport() |
| 124 | ->OnMessageReceived(msg)) |
| 125 | return true; |
| 126 | #endif |
| 127 | |
[email protected] | f24a1e2b | 2011-04-08 01:48:48 | [diff] [blame] | 128 | return gpu_channel_manager_.get() && |
| 129 | gpu_channel_manager_->OnMessageReceived(msg); |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | void GpuChildThread::OnInitialize() { |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 133 | // Record initialization only after collecting the GPU info because that can |
| 134 | // take a significant amount of time. |
| 135 | gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
[email protected] | fd00eee5 | 2013-05-24 22:32:28 | [diff] [blame] | 136 | Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); |
[email protected] | ec4bda6 | 2013-06-14 15:51:03 | [diff] [blame] | 137 | while (!deferred_messages_.empty()) { |
| 138 | Send(deferred_messages_.front()); |
| 139 | deferred_messages_.pop(); |
| 140 | } |
[email protected] | 9665973 | 2012-08-24 01:55:17 | [diff] [blame] | 141 | |
[email protected] | 0b2cec6 | 2011-07-22 18:13:28 | [diff] [blame] | 142 | if (dead_on_arrival_) { |
[email protected] | d7c2942 | 2014-03-11 06:08:57 | [diff] [blame] | 143 | LOG(ERROR) << "Exiting GPU process due to errors during initialization"; |
[email protected] | dd32b127 | 2013-05-04 14:17:11 | [diff] [blame] | 144 | base::MessageLoop::current()->Quit(); |
[email protected] | 37cfa2a | 2012-08-20 20:29:39 | [diff] [blame] | 145 | return; |
[email protected] | 0b2cec6 | 2011-07-22 18:13:28 | [diff] [blame] | 146 | } |
| 147 | |
[email protected] | e9875de7 | 2013-01-24 01:55:06 | [diff] [blame] | 148 | #if defined(OS_ANDROID) |
[email protected] | b38864d | 2013-05-24 14:42:36 | [diff] [blame] | 149 | base::PlatformThread::SetThreadPriority( |
| 150 | base::PlatformThread::CurrentHandle(), |
| 151 | base::kThreadPriority_Display); |
[email protected] | e9875de7 | 2013-01-24 01:55:06 | [diff] [blame] | 152 | #endif |
| 153 | |
[email protected] | 2d9de411 | 2011-05-27 03:18:36 | [diff] [blame] | 154 | // We don't need to pipe log messages if we are running the GPU thread in |
| 155 | // the browser process. |
[email protected] | 2d3de545 | 2013-01-18 10:03:40 | [diff] [blame] | 156 | if (!in_browser_process_) |
[email protected] | 2d9de411 | 2011-05-27 03:18:36 | [diff] [blame] | 157 | logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
[email protected] | 602cf9fda | 2011-04-22 16:53:30 | [diff] [blame] | 158 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 159 | // Defer creation of the render thread. This is to prevent it from handling |
| 160 | // IPC messages before the sandbox has been enabled and all other necessary |
| 161 | // initialization has succeeded. |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 162 | gpu_channel_manager_.reset( |
[email protected] | 4795329 | 2014-03-13 10:15:37 | [diff] [blame] | 163 | new GpuChannelManager(GetRouter(), |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 164 | watchdog_thread_.get(), |
| 165 | ChildProcess::current()->io_message_loop_proxy(), |
alexst | 0269a5c | 2014-09-10 05:15:12 | [diff] [blame] | 166 | ChildProcess::current()->GetShutDownEvent(), |
| 167 | channel())); |
[email protected] | 929881f | 2014-06-20 21:00:36 | [diff] [blame] | 168 | |
| 169 | #if defined(USE_OZONE) |
| 170 | ui::OzonePlatform::GetInstance() |
| 171 | ->GetGpuPlatformSupport() |
| 172 | ->OnChannelEstablished(this); |
| 173 | #endif |
[email protected] | 7709e71 | 2011-01-07 17:57:31 | [diff] [blame] | 174 | } |
| 175 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 176 | void GpuChildThread::StopWatchdog() { |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 177 | if (watchdog_thread_.get()) { |
[email protected] | 7709e71 | 2011-01-07 17:57:31 | [diff] [blame] | 178 | watchdog_thread_->Stop(); |
| 179 | } |
[email protected] | c0fc094 | 2010-01-13 00:55:37 | [diff] [blame] | 180 | } |
| 181 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 182 | void GpuChildThread::OnCollectGraphicsInfo() { |
[email protected] | 7741f2e | 2012-12-06 01:29:13 | [diff] [blame] | 183 | #if defined(OS_WIN) |
| 184 | // GPU full info collection should only happen on un-sandboxed GPU process |
| 185 | // or single process/in-process gpu mode on Windows. |
[email protected] | 56403c2 | 2012-10-04 18:27:04 | [diff] [blame] | 186 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | 7741f2e | 2012-12-06 01:29:13 | [diff] [blame] | 187 | DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |
[email protected] | 2d3de545 | 2013-01-18 10:03:40 | [diff] [blame] | 188 | in_browser_process_); |
[email protected] | 7741f2e | 2012-12-06 01:29:13 | [diff] [blame] | 189 | #endif // OS_WIN |
[email protected] | f3f79b10 | 2011-01-27 00:19:37 | [diff] [blame] | 190 | |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 191 | gpu::CollectInfoResult result = |
| 192 | gpu::CollectContextGraphicsInfo(&gpu_info_); |
| 193 | switch (result) { |
| 194 | case gpu::kCollectInfoFatalFailure: |
| 195 | LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; |
| 196 | // TODO(piman): can we signal overall failure? |
| 197 | break; |
| 198 | case gpu::kCollectInfoNonFatalFailure: |
| 199 | VLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; |
| 200 | break; |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 201 | case gpu::kCollectInfoNone: |
| 202 | NOTREACHED(); |
| 203 | break; |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 204 | case gpu::kCollectInfoSuccess: |
| 205 | break; |
| 206 | } |
[email protected] | 7741f2e | 2012-12-06 01:29:13 | [diff] [blame] | 207 | GetContentClient()->SetGpuInfo(gpu_info_); |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 208 | |
| 209 | #if defined(OS_WIN) |
[email protected] | 87a735d | 2012-12-07 01:52:44 | [diff] [blame] | 210 | // This is slow, but it's the only thing the unsandboxed GPU process does, |
| 211 | // and GpuDataManager prevents us from sending multiple collecting requests, |
| 212 | // so it's OK to be blocking. |
[email protected] | d7b5cc7 | 2013-05-23 20:05:00 | [diff] [blame] | 213 | gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics); |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 214 | gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess; |
[email protected] | 87a735d | 2012-12-07 01:52:44 | [diff] [blame] | 215 | #endif // OS_WIN |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 216 | |
[email protected] | 87a735d | 2012-12-07 01:52:44 | [diff] [blame] | 217 | Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |
| 218 | |
| 219 | #if defined(OS_WIN) |
[email protected] | 2d3de545 | 2013-01-18 10:03:40 | [diff] [blame] | 220 | if (!in_browser_process_) { |
[email protected] | 87a735d | 2012-12-07 01:52:44 | [diff] [blame] | 221 | // The unsandboxed GPU process fulfilled its duty. Rest in peace. |
[email protected] | dd32b127 | 2013-05-04 14:17:11 | [diff] [blame] | 222 | base::MessageLoop::current()->Quit(); |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 223 | } |
[email protected] | 7741f2e | 2012-12-06 01:29:13 | [diff] [blame] | 224 | #endif // OS_WIN |
[email protected] | cadc050 | 2010-09-10 20:27:13 | [diff] [blame] | 225 | } |
[email protected] | 43ed628 | 2010-09-15 20:07:19 | [diff] [blame] | 226 | |
[email protected] | fb246af | 2012-08-18 03:11:41 | [diff] [blame] | 227 | void GpuChildThread::OnGetVideoMemoryUsageStats() { |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 228 | GPUVideoMemoryUsageStats video_memory_usage_stats; |
[email protected] | 59383c78 | 2013-04-17 16:43:27 | [diff] [blame] | 229 | if (gpu_channel_manager_) |
[email protected] | fb246af | 2012-08-18 03:11:41 | [diff] [blame] | 230 | gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
[email protected] | 879c7dfd | 2012-12-19 21:44:37 | [diff] [blame] | 231 | &video_memory_usage_stats); |
[email protected] | fb246af | 2012-08-18 03:11:41 | [diff] [blame] | 232 | Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); |
| 233 | } |
| 234 | |
[email protected] | 184e3f380 | 2011-05-04 20:48:52 | [diff] [blame] | 235 | void GpuChildThread::OnClean() { |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 236 | VLOG(1) << "GPU: Removing all contexts"; |
[email protected] | 59383c78 | 2013-04-17 16:43:27 | [diff] [blame] | 237 | if (gpu_channel_manager_) |
[email protected] | 184e3f380 | 2011-05-04 20:48:52 | [diff] [blame] | 238 | gpu_channel_manager_->LoseAllContexts(); |
| 239 | } |
| 240 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 241 | void GpuChildThread::OnCrash() { |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 242 | VLOG(1) << "GPU: Simulating GPU crash"; |
[email protected] | 43ed628 | 2010-09-15 20:07:19 | [diff] [blame] | 243 | // Good bye, cruel world. |
| 244 | volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; |
| 245 | *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
| 246 | } |
[email protected] | 259750d | 2010-09-24 06:14:00 | [diff] [blame] | 247 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 248 | void GpuChildThread::OnHang() { |
[email protected] | 085170ca | 2012-05-17 20:27:28 | [diff] [blame] | 249 | VLOG(1) << "GPU: Simulating GPU hang"; |
[email protected] | 981c1c5 | 2010-12-01 20:09:24 | [diff] [blame] | 250 | for (;;) { |
| 251 | // Do not sleep here. The GPU watchdog timer tracks the amount of user |
| 252 | // time this thread is using and it doesn't use much while calling Sleep. |
| 253 | } |
[email protected] | 259750d | 2010-09-24 06:14:00 | [diff] [blame] | 254 | } |
[email protected] | 41579ae | 2010-11-15 22:31:26 | [diff] [blame] | 255 | |
[email protected] | 31583a9d | 2012-11-30 00:37:17 | [diff] [blame] | 256 | void GpuChildThread::OnDisableWatchdog() { |
| 257 | VLOG(1) << "GPU: Disabling watchdog thread"; |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 258 | if (watchdog_thread_.get()) { |
[email protected] | 31583a9d | 2012-11-30 00:37:17 | [diff] [blame] | 259 | // Disarm the watchdog before shutting down the message loop. This prevents |
| 260 | // the future posting of tasks to the message loop. |
| 261 | if (watchdog_thread_->message_loop()) |
| 262 | watchdog_thread_->PostAcknowledge(); |
| 263 | // Prevent rearming. |
| 264 | watchdog_thread_->Stop(); |
| 265 | } |
| 266 | } |
| 267 | |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 268 | } // namespace content |
| 269 | |