OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 #endif | 61 #endif |
62 | 62 |
63 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 63 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
64 #include "ui/gfx/x/x11_switches.h" | 64 #include "ui/gfx/x/x11_switches.h" |
65 #endif | 65 #endif |
66 | 66 |
67 namespace content { | 67 namespace content { |
68 | 68 |
69 bool GpuProcessHost::gpu_enabled_ = true; | 69 bool GpuProcessHost::gpu_enabled_ = true; |
70 bool GpuProcessHost::hardware_gpu_enabled_ = true; | 70 bool GpuProcessHost::hardware_gpu_enabled_ = true; |
71 int GpuProcessHost::gpu_crash_count_ = 0; | |
72 int GpuProcessHost::gpu_recent_crash_count_ = 0; | |
73 base::Time GpuProcessHost::last_gpu_crash_time_; | |
Ken Russell (switch to Gerrit)
2014/07/25 21:21:36
We need to ensure that this doesn't add any static
| |
74 bool GpuProcessHost::crashed_before_ = false; | |
75 int GpuProcessHost::swiftshader_crash_count_ = 0; | |
71 | 76 |
72 namespace { | 77 namespace { |
73 | 78 |
74 enum GPUProcessLifetimeEvent { | 79 enum GPUProcessLifetimeEvent { |
75 LAUNCHED, | 80 LAUNCHED, |
76 DIED_FIRST_TIME, | 81 DIED_FIRST_TIME, |
77 DIED_SECOND_TIME, | 82 DIED_SECOND_TIME, |
78 DIED_THIRD_TIME, | 83 DIED_THIRD_TIME, |
79 DIED_FOURTH_TIME, | 84 DIED_FOURTH_TIME, |
80 GPU_PROCESS_LIFETIME_EVENT_MAX = 100 | 85 GPU_PROCESS_LIFETIME_EVENT_MAX = 100 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 GpuProcessHost::~GpuProcessHost() { | 364 GpuProcessHost::~GpuProcessHost() { |
360 DCHECK(CalledOnValidThread()); | 365 DCHECK(CalledOnValidThread()); |
361 | 366 |
362 SendOutstandingReplies(); | 367 SendOutstandingReplies(); |
363 | 368 |
364 // Maximum number of times the gpu process is allowed to crash in a session. | 369 // Maximum number of times the gpu process is allowed to crash in a session. |
365 // Once this limit is reached, any request to launch the gpu process will | 370 // Once this limit is reached, any request to launch the gpu process will |
366 // fail. | 371 // fail. |
367 const int kGpuMaxCrashCount = 3; | 372 const int kGpuMaxCrashCount = 3; |
368 | 373 |
369 // Number of times the gpu process has crashed in the current browser session. | |
370 static int gpu_crash_count = 0; | |
371 static int gpu_recent_crash_count = 0; | |
372 static base::Time last_gpu_crash_time; | |
373 static bool crashed_before = false; | |
374 static int swiftshader_crash_count = 0; | |
375 | |
376 bool disable_crash_limit = CommandLine::ForCurrentProcess()->HasSwitch( | 374 bool disable_crash_limit = CommandLine::ForCurrentProcess()->HasSwitch( |
377 switches::kDisableGpuProcessCrashLimit); | 375 switches::kDisableGpuProcessCrashLimit); |
378 | 376 |
379 // Ending only acts as a failure if the GPU process was actually started and | 377 // Ending only acts as a failure if the GPU process was actually started and |
380 // was intended for actual rendering (and not just checking caps or other | 378 // was intended for actual rendering (and not just checking caps or other |
381 // options). | 379 // options). |
382 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) { | 380 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) { |
383 if (swiftshader_rendering_) { | 381 if (swiftshader_rendering_) { |
384 UMA_HISTOGRAM_ENUMERATION("GPU.SwiftShaderLifetimeEvents", | 382 UMA_HISTOGRAM_ENUMERATION("GPU.SwiftShaderLifetimeEvents", |
385 DIED_FIRST_TIME + swiftshader_crash_count, | 383 DIED_FIRST_TIME + swiftshader_crash_count_, |
386 GPU_PROCESS_LIFETIME_EVENT_MAX); | 384 GPU_PROCESS_LIFETIME_EVENT_MAX); |
387 | 385 |
388 if (++swiftshader_crash_count >= kGpuMaxCrashCount && | 386 if (++swiftshader_crash_count_ >= kGpuMaxCrashCount && |
389 !disable_crash_limit) { | 387 !disable_crash_limit) { |
390 // SwiftShader is too unstable to use. Disable it for current session. | 388 // SwiftShader is too unstable to use. Disable it for current session. |
391 gpu_enabled_ = false; | 389 gpu_enabled_ = false; |
392 } | 390 } |
393 } else { | 391 } else { |
394 ++gpu_crash_count; | 392 ++gpu_crash_count_; |
395 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 393 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
396 std::min(DIED_FIRST_TIME + gpu_crash_count, | 394 std::min(DIED_FIRST_TIME + gpu_crash_count_, |
397 GPU_PROCESS_LIFETIME_EVENT_MAX - 1), | 395 GPU_PROCESS_LIFETIME_EVENT_MAX - 1), |
398 GPU_PROCESS_LIFETIME_EVENT_MAX); | 396 GPU_PROCESS_LIFETIME_EVENT_MAX); |
399 | 397 |
400 // Allow about 1 GPU crash per hour to be removed from the crash count, | 398 // Allow about 1 GPU crash per hour to be removed from the crash count, |
401 // so very occasional crashes won't eventually add up and prevent the | 399 // so very occasional crashes won't eventually add up and prevent the |
402 // GPU process from launching. | 400 // GPU process from launching. |
403 ++gpu_recent_crash_count; | 401 ++gpu_recent_crash_count_; |
404 base::Time current_time = base::Time::Now(); | 402 base::Time current_time = base::Time::Now(); |
405 if (crashed_before) { | 403 if (crashed_before_) { |
406 int hours_different = (current_time - last_gpu_crash_time).InHours(); | 404 int hours_different = (current_time - last_gpu_crash_time_).InHours(); |
407 gpu_recent_crash_count = | 405 gpu_recent_crash_count_ = |
408 std::max(0, gpu_recent_crash_count - hours_different); | 406 std::max(0, gpu_recent_crash_count_ - hours_different); |
409 } | 407 } |
410 | 408 |
411 crashed_before = true; | 409 crashed_before_ = true; |
412 last_gpu_crash_time = current_time; | 410 last_gpu_crash_time_ = current_time; |
413 | 411 |
414 if ((gpu_recent_crash_count >= kGpuMaxCrashCount && !disable_crash_limit) | 412 if ((gpu_recent_crash_count_ >= kGpuMaxCrashCount && |
415 || !initialized_) { | 413 !disable_crash_limit) || |
414 !initialized_) { | |
416 #if !defined(OS_CHROMEOS) | 415 #if !defined(OS_CHROMEOS) |
417 // The gpu process is too unstable to use. Disable it for current | 416 // The gpu process is too unstable to use. Disable it for current |
418 // session. | 417 // session. |
419 hardware_gpu_enabled_ = false; | 418 hardware_gpu_enabled_ = false; |
420 GpuDataManagerImpl::GetInstance()->DisableHardwareAcceleration(); | 419 GpuDataManagerImpl::GetInstance()->DisableHardwareAcceleration(); |
421 #endif | 420 #endif |
422 } | 421 } |
423 } | 422 } |
424 } | 423 } |
425 | 424 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1067 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1069 ClientIdToShaderCacheMap::iterator iter = | 1068 ClientIdToShaderCacheMap::iterator iter = |
1070 client_id_to_shader_cache_.find(client_id); | 1069 client_id_to_shader_cache_.find(client_id); |
1071 // If the cache doesn't exist then this is an off the record profile. | 1070 // If the cache doesn't exist then this is an off the record profile. |
1072 if (iter == client_id_to_shader_cache_.end()) | 1071 if (iter == client_id_to_shader_cache_.end()) |
1073 return; | 1072 return; |
1074 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1073 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1075 } | 1074 } |
1076 | 1075 |
1077 } // namespace content | 1076 } // namespace content |
OLD | NEW |