| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 while (!queued_messages_.empty()) { | 450 while (!queued_messages_.empty()) { |
| 451 delete queued_messages_.front(); | 451 delete queued_messages_.front(); |
| 452 queued_messages_.pop(); | 452 queued_messages_.pop(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 // This is only called on the IO thread so no race against the constructor | 455 // This is only called on the IO thread so no race against the constructor |
| 456 // for another GpuProcessHost. | 456 // for another GpuProcessHost. |
| 457 if (g_gpu_process_hosts[kind_] == this) | 457 if (g_gpu_process_hosts[kind_] == this) |
| 458 g_gpu_process_hosts[kind_] = NULL; | 458 g_gpu_process_hosts[kind_] = NULL; |
| 459 | 459 |
| 460 // If there are any remaining offscreen contexts at the point the | |
| 461 // GPU process exits, assume something went wrong, and block their | |
| 462 // URLs from accessing client 3D APIs without prompting. | |
| 463 BlockLiveOffscreenContexts(); | |
| 464 | |
| 465 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", | 460 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", |
| 466 GpuSurfaceTracker::Get()->GetSurfaceCount()); | 461 GpuSurfaceTracker::Get()->GetSurfaceCount()); |
| 467 UMA_HISTOGRAM_BOOLEAN("GPU.AtExitReceivedMemoryStats", | 462 UMA_HISTOGRAM_BOOLEAN("GPU.AtExitReceivedMemoryStats", |
| 468 uma_memory_stats_received_); | 463 uma_memory_stats_received_); |
| 469 | 464 |
| 470 if (uma_memory_stats_received_) { | 465 if (uma_memory_stats_received_) { |
| 471 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitContextGroupCount", | 466 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitContextGroupCount", |
| 472 uma_memory_stats_.context_group_count); | 467 uma_memory_stats_.context_group_count); |
| 473 UMA_HISTOGRAM_CUSTOM_COUNTS( | 468 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 474 "GPU.AtExitMBytesAllocated", | 469 "GPU.AtExitMBytesAllocated", |
| 475 uma_memory_stats_.bytes_allocated_current / 1024 / 1024, 1, 2000, 50); | 470 uma_memory_stats_.bytes_allocated_current / 1024 / 1024, 1, 2000, 50); |
| 476 UMA_HISTOGRAM_CUSTOM_COUNTS( | 471 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 477 "GPU.AtExitMBytesAllocatedMax", | 472 "GPU.AtExitMBytesAllocatedMax", |
| 478 uma_memory_stats_.bytes_allocated_max / 1024 / 1024, 1, 2000, 50); | 473 uma_memory_stats_.bytes_allocated_max / 1024 / 1024, 1, 2000, 50); |
| 479 } | 474 } |
| 480 | 475 |
| 481 std::string message; | 476 std::string message; |
| 477 bool block_offscreen_contexts = true; |
| 482 if (!in_process_) { | 478 if (!in_process_) { |
| 483 int exit_code; | 479 int exit_code; |
| 484 base::TerminationStatus status = process_->GetTerminationStatus( | 480 base::TerminationStatus status = process_->GetTerminationStatus( |
| 485 false /* known_dead */, &exit_code); | 481 false /* known_dead */, &exit_code); |
| 486 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", | 482 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", |
| 487 status, | 483 status, |
| 488 base::TERMINATION_STATUS_MAX_ENUM); | 484 base::TERMINATION_STATUS_MAX_ENUM); |
| 489 | 485 |
| 490 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || | 486 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || |
| 491 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | 487 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
| 492 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", | 488 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", |
| 493 exit_code, | 489 exit_code, |
| 494 RESULT_CODE_LAST_CODE); | 490 RESULT_CODE_LAST_CODE); |
| 495 } | 491 } |
| 496 | 492 |
| 497 switch (status) { | 493 switch (status) { |
| 498 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 494 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
| 495 // Don't block offscreen contexts (and force page reload for webgl) |
| 496 // if this was an intentional shutdown or the OOM killer on Android |
| 497 // killed us while Chrome was in the background. |
| 498 block_offscreen_contexts = false; |
| 499 message = "The GPU process exited normally. Everything is okay."; | 499 message = "The GPU process exited normally. Everything is okay."; |
| 500 break; | 500 break; |
| 501 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 501 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 502 message = base::StringPrintf( | 502 message = base::StringPrintf( |
| 503 "The GPU process exited with code %d.", | 503 "The GPU process exited with code %d.", |
| 504 exit_code); | 504 exit_code); |
| 505 break; | 505 break; |
| 506 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 506 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
| 507 message = "You killed the GPU process! Why?"; | 507 message = "You killed the GPU process! Why?"; |
| 508 break; | 508 break; |
| 509 #if defined(OS_CHROMEOS) | 509 #if defined(OS_CHROMEOS) |
| 510 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 510 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
| 511 message = "The GUP process was killed due to out of memory."; | 511 message = "The GUP process was killed due to out of memory."; |
| 512 break; | 512 break; |
| 513 #endif | 513 #endif |
| 514 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 514 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 515 message = "The GPU process crashed!"; | 515 message = "The GPU process crashed!"; |
| 516 break; | 516 break; |
| 517 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 517 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
| 518 message = "The GPU process failed to start!"; | 518 message = "The GPU process failed to start!"; |
| 519 break; | 519 break; |
| 520 default: | 520 default: |
| 521 break; | 521 break; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 // If there are any remaining offscreen contexts at the point the |
| 526 // GPU process exits, assume something went wrong, and block their |
| 527 // URLs from accessing client 3D APIs without prompting. |
| 528 if (block_offscreen_contexts) |
| 529 BlockLiveOffscreenContexts(); |
| 530 |
| 525 BrowserThread::PostTask(BrowserThread::UI, | 531 BrowserThread::PostTask(BrowserThread::UI, |
| 526 FROM_HERE, | 532 FROM_HERE, |
| 527 base::Bind(&GpuProcessHostUIShim::Destroy, | 533 base::Bind(&GpuProcessHostUIShim::Destroy, |
| 528 host_id_, | 534 host_id_, |
| 529 message)); | 535 message)); |
| 530 } | 536 } |
| 531 | 537 |
| 532 bool GpuProcessHost::Init() { | 538 bool GpuProcessHost::Init() { |
| 533 init_start_time_ = base::TimeTicks::Now(); | 539 init_start_time_ = base::TimeTicks::Now(); |
| 534 | 540 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1162 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1157 ClientIdToShaderCacheMap::iterator iter = | 1163 ClientIdToShaderCacheMap::iterator iter = |
| 1158 client_id_to_shader_cache_.find(client_id); | 1164 client_id_to_shader_cache_.find(client_id); |
| 1159 // If the cache doesn't exist then this is an off the record profile. | 1165 // If the cache doesn't exist then this is an off the record profile. |
| 1160 if (iter == client_id_to_shader_cache_.end()) | 1166 if (iter == client_id_to_shader_cache_.end()) |
| 1161 return; | 1167 return; |
| 1162 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1168 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1163 } | 1169 } |
| 1164 | 1170 |
| 1165 } // namespace content | 1171 } // namespace content |
| OLD | NEW |