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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 host_id = ++last_host_id; | 323 host_id = ++last_host_id; |
324 | 324 |
325 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLaunchCause", | 325 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLaunchCause", |
326 cause, | 326 cause, |
327 CAUSE_FOR_GPU_LAUNCH_MAX_ENUM); | 327 CAUSE_FOR_GPU_LAUNCH_MAX_ENUM); |
328 | 328 |
329 GpuProcessHost* host = new GpuProcessHost(host_id, kind); | 329 GpuProcessHost* host = new GpuProcessHost(host_id, kind); |
330 if (host->Init()) | 330 if (host->Init()) |
331 return host; | 331 return host; |
332 | 332 |
333 // TODO(sievers): Revisit this behavior. It's not really a crash, but we also | |
334 // want the fallback-to-sw behavior if we cannot initialize the GPU. | |
335 RecordProcessCrash() | |
336 | |
333 delete host; | 337 delete host; |
334 return NULL; | 338 return NULL; |
335 } | 339 } |
336 | 340 |
337 // static | 341 // static |
338 void GpuProcessHost::GetProcessHandles( | 342 void GpuProcessHost::GetProcessHandles( |
339 const GpuDataManager::GetGpuProcessHandlesCallback& callback) { | 343 const GpuDataManager::GetGpuProcessHandlesCallback& callback) { |
340 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 344 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
341 BrowserThread::PostTask( | 345 BrowserThread::PostTask( |
342 BrowserThread::IO, | 346 BrowserThread::IO, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); | 427 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); |
424 | 428 |
425 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_GPU, this)); | 429 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_GPU, this)); |
426 } | 430 } |
427 | 431 |
428 GpuProcessHost::~GpuProcessHost() { | 432 GpuProcessHost::~GpuProcessHost() { |
429 DCHECK(CalledOnValidThread()); | 433 DCHECK(CalledOnValidThread()); |
430 | 434 |
431 SendOutstandingReplies(); | 435 SendOutstandingReplies(); |
432 | 436 |
433 RecordProcessCrash(); | |
434 | |
435 // In case we never started, clean up. | 437 // In case we never started, clean up. |
436 while (!queued_messages_.empty()) { | 438 while (!queued_messages_.empty()) { |
437 delete queued_messages_.front(); | 439 delete queued_messages_.front(); |
438 queued_messages_.pop(); | 440 queued_messages_.pop(); |
439 } | 441 } |
440 | 442 |
441 #if defined(OS_MACOSX) && !defined(OS_IOS) | 443 #if defined(OS_MACOSX) && !defined(OS_IOS) |
442 if (!io_surface_manager_token_.IsZero()) { | 444 if (!io_surface_manager_token_.IsZero()) { |
443 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); | 445 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); |
444 io_surface_manager_token_.SetZero(); | 446 io_surface_manager_token_.SetZero(); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 const IPC::Message& message) { | 871 const IPC::Message& message) { |
870 RenderWidgetResizeHelper::Get()->PostGpuProcessMsg(host_id_, message); | 872 RenderWidgetResizeHelper::Get()->PostGpuProcessMsg(host_id_, message); |
871 } | 873 } |
872 #endif | 874 #endif |
873 | 875 |
874 void GpuProcessHost::OnProcessLaunched() { | 876 void GpuProcessHost::OnProcessLaunched() { |
875 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 877 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
876 base::TimeTicks::Now() - init_start_time_); | 878 base::TimeTicks::Now() - init_start_time_); |
877 } | 879 } |
878 | 880 |
881 void GpuProcessHost::OnProcessLaunchFailed() { | |
882 RecordProcessCrash(); | |
883 } | |
884 | |
879 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 885 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
880 SendOutstandingReplies(); | 886 SendOutstandingReplies(); |
881 RecordProcessCrash(); | 887 RecordProcessCrash(); |
882 GpuDataManagerImpl::GetInstance()->ProcessCrashed( | 888 GpuDataManagerImpl::GetInstance()->ProcessCrashed( |
883 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 889 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
884 } | 890 } |
885 | 891 |
886 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { | 892 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
887 return kind_; | 893 return kind_; |
888 } | 894 } |
889 | 895 |
890 void GpuProcessHost::ForceShutdown() { | 896 void GpuProcessHost::ForceShutdown() { |
891 // This is only called on the IO thread so no race against the constructor | 897 // This is only called on the IO thread so no race against the constructor |
892 // for another GpuProcessHost. | 898 // for another GpuProcessHost. |
893 if (g_gpu_process_hosts[kind_] == this) | 899 if (g_gpu_process_hosts[kind_] == this) |
894 g_gpu_process_hosts[kind_] = NULL; | 900 g_gpu_process_hosts[kind_] = NULL; |
895 | 901 |
896 #if defined(OS_MACOSX) && !defined(OS_IOS) | 902 #if defined(OS_MACOSX) && !defined(OS_IOS) |
897 if (!io_surface_manager_token_.IsZero()) { | 903 if (!io_surface_manager_token_.IsZero()) { |
898 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); | 904 BrowserIOSurfaceManager::GetInstance()->InvalidateGpuProcessToken(); |
899 io_surface_manager_token_.SetZero(); | 905 io_surface_manager_token_.SetZero(); |
900 } | 906 } |
901 #endif | 907 #endif |
902 | 908 |
903 process_->ForceShutdown(); | 909 process_->ForceShutdown(); |
904 } | 910 } |
905 | 911 |
912 void GpuProcessHost::StopGpuProcess() { | |
913 Send(new GpuMsg_Finalize()); | |
914 } | |
915 | |
906 void GpuProcessHost::BeginFrameSubscription( | 916 void GpuProcessHost::BeginFrameSubscription( |
907 int surface_id, | 917 int surface_id, |
908 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 918 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
909 frame_subscribers_[surface_id] = subscriber; | 919 frame_subscribers_[surface_id] = subscriber; |
910 } | 920 } |
911 | 921 |
912 void GpuProcessHost::EndFrameSubscription(int surface_id) { | 922 void GpuProcessHost::EndFrameSubscription(int surface_id) { |
913 frame_subscribers_.erase(surface_id); | 923 frame_subscribers_.erase(surface_id); |
914 } | 924 } |
915 | 925 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 for (std::multiset<GURL>::iterator iter = | 1030 for (std::multiset<GURL>::iterator iter = |
1021 urls_with_live_offscreen_contexts_.begin(); | 1031 urls_with_live_offscreen_contexts_.begin(); |
1022 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1032 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
1023 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1033 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
1024 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1034 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
1025 } | 1035 } |
1026 } | 1036 } |
1027 | 1037 |
1028 void GpuProcessHost::RecordProcessCrash() { | 1038 void GpuProcessHost::RecordProcessCrash() { |
1029 // Skip if a GPU process crash was already counted. | 1039 // Skip if a GPU process crash was already counted. |
1030 if (gpu_crash_recorded_) | 1040 if (gpu_crash_recorded_) |
no sievers
2015/07/29 19:05:19
You can remove this boolean also now, as with your
| |
1031 return; | 1041 return; |
1032 | 1042 |
1033 // Maximum number of times the GPU process is allowed to crash in a session. | 1043 // Maximum number of times the GPU process is allowed to crash in a session. |
1034 // Once this limit is reached, any request to launch the GPU process will | 1044 // Once this limit is reached, any request to launch the GPU process will |
1035 // fail. | 1045 // fail. |
1036 const int kGpuMaxCrashCount = 3; | 1046 const int kGpuMaxCrashCount = 3; |
1037 | 1047 |
1038 // Last time the GPU process crashed. | 1048 // Last time the GPU process crashed. |
1039 static base::Time last_gpu_crash_time; | 1049 static base::Time last_gpu_crash_time; |
1040 | 1050 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1149 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1140 ClientIdToShaderCacheMap::iterator iter = | 1150 ClientIdToShaderCacheMap::iterator iter = |
1141 client_id_to_shader_cache_.find(client_id); | 1151 client_id_to_shader_cache_.find(client_id); |
1142 // If the cache doesn't exist then this is an off the record profile. | 1152 // If the cache doesn't exist then this is an off the record profile. |
1143 if (iter == client_id_to_shader_cache_.end()) | 1153 if (iter == client_id_to_shader_cache_.end()) |
1144 return; | 1154 return; |
1145 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1155 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1146 } | 1156 } |
1147 | 1157 |
1148 } // namespace content | 1158 } // namespace content |
OLD | NEW |