Commit ba08c24e authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Do not launch the GPU info collection process if the device id is 0

By the time the GPU info collection is requested, the GPU vendor id
and device id should be available. Something must be wrong if the
device id is 0. In this case, no need to collect GPU info.

This CL also renames the info collection GPU process from
GPU_PROCESS_KIND_UNSANDBOXED_NO_GL to
GPU_PROCESS_KIND_INFO_COLLECTION

Bug: 896565
Change-Id: I00e1a70448f337f148ae7ad4f016d2308c284fba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036940
Commit-Queue: Maggie Chen <magchen@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738682}
parent 3776bf00
...@@ -601,8 +601,8 @@ void GpuServiceImpl::GetGpuSupportedRuntimeVersionAndDevicePerfInfo( ...@@ -601,8 +601,8 @@ void GpuServiceImpl::GetGpuSupportedRuntimeVersionAndDevicePerfInfo(
std::move(callback).Run(gpu_info_.dx12_vulkan_version_info, std::move(callback).Run(gpu_info_.dx12_vulkan_version_info,
device_perf_info_.value()); device_perf_info_.value());
// The unsandboxed GPU process fulfilled its duty and Dxdiag task is not // The unsandboxed GPU info collection process fulfilled its duty and Dxdiag
// running. Bye bye. // task is not running. Bye bye.
if (!long_dx_task_different_thread_in_progress_) if (!long_dx_task_different_thread_in_progress_)
MaybeExit(false); MaybeExit(false);
} }
...@@ -624,7 +624,8 @@ void GpuServiceImpl::RequestCompleteGpuInfo( ...@@ -624,7 +624,8 @@ void GpuServiceImpl::RequestCompleteGpuInfo(
[](GpuServiceImpl* gpu_service, [](GpuServiceImpl* gpu_service,
RequestCompleteGpuInfoCallback callback) { RequestCompleteGpuInfoCallback callback) {
std::move(callback).Run(gpu_service->gpu_info_.dx_diagnostics); std::move(callback).Run(gpu_service->gpu_info_.dx_diagnostics);
// The unsandboxed GPU process fulfilled its duty. Bye bye. // The unsandboxed GPU info collection process fulfilled its duty.
// Bye bye.
gpu_service->long_dx_task_different_thread_in_progress_ = false; gpu_service->long_dx_task_different_thread_in_progress_ = false;
gpu_service->MaybeExit(false); gpu_service->MaybeExit(false);
}, },
...@@ -992,9 +993,9 @@ void GpuServiceImpl::MaybeExit(bool for_context_loss) { ...@@ -992,9 +993,9 @@ void GpuServiceImpl::MaybeExit(bool for_context_loss) {
"from errors. GPU process will restart shortly."; "from errors. GPU process will restart shortly.";
} }
is_exiting_.Set(); is_exiting_.Set();
// For the unsandboxed GPU process used for info collection, if we exit // For the unsandboxed GPU info collection process used for info collection,
// immediately, then the reply message could be lost. That's why the // if we exit immediately, then the reply message could be lost. That's why
// |exit_callback_| takes the boolean argument. // the |exit_callback_| takes the boolean argument.
std::move(exit_callback_).Run(/*immediately=*/for_context_loss); std::move(exit_callback_).Run(/*immediately=*/for_context_loss);
} }
......
...@@ -613,24 +613,27 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData() { ...@@ -613,24 +613,27 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData() {
gpu_info_dx_diag_requested_ = true; gpu_info_dx_diag_requested_ = true;
base::OnceClosure task = base::BindOnce([]() { base::OnceClosure task = base::BindOnce([]() {
// No info collection for software GL implementation (id == 0xffff). GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
// There are a few crash reports on exit_or_terminate_process() during // No info collection for software GL implementation (id == 0xffff) or
// process teardown. // abnormal situation (id == 0). There are a few crash reports on
const gpu::GPUInfo::GPUDevice gpu = // exit_or_terminate_process() during process teardown. The GPU ID
GpuDataManagerImpl::GetInstance()->GetGPUInfo().gpu; // should be available by the time this task starts to run.
if (gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) { // This request comes from chrome://gpu page.
GpuDataManagerImpl::GetInstance()->UpdateDxDiagNodeRequestStatus(false); const gpu::GPUInfo::GPUDevice gpu = manager->GetGPUInfo().gpu;
if ((gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) ||
(gpu.vendor_id == 0 && gpu.device_id == 0)) {
manager->UpdateDxDiagNodeRequestStatus(false);
return; return;
} }
GpuProcessHost* host = GpuProcessHost::Get( GpuProcessHost* host = GpuProcessHost::Get(GPU_PROCESS_KIND_INFO_COLLECTION,
GPU_PROCESS_KIND_UNSANDBOXED_NO_GL, true /* force_create */); true /* force_create */);
if (!host) { if (!host) {
GpuDataManagerImpl::GetInstance()->UpdateDxDiagNodeRequestStatus(false); manager->UpdateDxDiagNodeRequestStatus(false);
return; return;
} }
GpuDataManagerImpl::GetInstance()->UpdateDxDiagNodeRequestStatus(true); manager->UpdateDxDiagNodeRequestStatus(true);
host->gpu_service()->RequestCompleteGpuInfo( host->gpu_service()->RequestCompleteGpuInfo(
base::BindOnce([](const gpu::DxDiagNode& dx_diagnostics) { base::BindOnce([](const gpu::DxDiagNode& dx_diagnostics) {
GpuDataManagerImpl::GetInstance()->UpdateDxDiagNode(dx_diagnostics); GpuDataManagerImpl::GetInstance()->UpdateDxDiagNode(dx_diagnostics);
...@@ -644,35 +647,41 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData() { ...@@ -644,35 +647,41 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData() {
void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion(
bool delayed) { bool delayed) {
#if defined(OS_WIN) #if defined(OS_WIN)
base::OnceClosure task = base::BindOnce([]() { base::OnceClosure task = base::BindOnce(
if (GpuDataManagerImpl::GetInstance()->Dx12VulkanRequested()) [](bool delayed) {
return; GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
if (manager->Dx12VulkanRequested())
// No info collection for software GL implementation (id == 0xffff). return;
// There are a few crash reports on exit_or_terminate_process() during
// process teardown. // No info collection for software GL implementation (id == 0xffff) or
const gpu::GPUInfo::GPUDevice gpu = // abnormal situation (id == 0). There are a few crash reports on
GpuDataManagerImpl::GetInstance()->GetGPUInfo().gpu; // exit_or_terminate_process() during process teardown. The GPU ID
if (gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) { // should be available by the time this task starts to run. In the case
GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanRequestStatus(false); // of no delay, which is for testing only, don't check the GPU ID
return; // because the ID is not available yet.
} const gpu::GPUInfo::GPUDevice gpu = manager->GetGPUInfo().gpu;
if ((gpu.vendor_id == 0xffff && gpu.device_id == 0xffff) ||
(delayed && gpu.vendor_id == 0 && gpu.device_id == 0)) {
manager->UpdateDx12VulkanRequestStatus(false);
return;
}
GpuProcessHost* host = GpuProcessHost::Get( GpuProcessHost* host = GpuProcessHost::Get(
GPU_PROCESS_KIND_UNSANDBOXED_NO_GL, true /* force_create */); GPU_PROCESS_KIND_INFO_COLLECTION, true /* force_create */);
if (!host) { if (!host) {
GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanRequestStatus(false); manager->UpdateDx12VulkanRequestStatus(false);
return; return;
} }
GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanRequestStatus(true); manager->UpdateDx12VulkanRequestStatus(true);
host->gpu_service()->GetGpuSupportedRuntimeVersionAndDevicePerfInfo( host->gpu_service()->GetGpuSupportedRuntimeVersionAndDevicePerfInfo(
base::BindOnce([](const gpu::Dx12VulkanVersionInfo& info, base::BindOnce([](const gpu::Dx12VulkanVersionInfo& info,
const gpu::DevicePerfInfo& device_perf_info) { const gpu::DevicePerfInfo& device_perf_info) {
GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanInfo(info); GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanInfo(info);
// TODO(zmo): Process collected DevicePerfInfo. // TODO(zmo): Process collected DevicePerfInfo.
})); }));
}); },
delayed);
if (delayed) { if (delayed) {
base::PostDelayedTask(FROM_HERE, {BrowserThread::IO}, std::move(task), base::PostDelayedTask(FROM_HERE, {BrowserThread::IO}, std::move(task),
...@@ -983,14 +992,14 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences( ...@@ -983,14 +992,14 @@ void GpuDataManagerImplPrivate::UpdateGpuPreferences(
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
gpu_preferences->gpu_startup_dialog = gpu_preferences->gpu_startup_dialog =
#if defined(OS_WIN) #if defined(OS_WIN)
(kind == GPU_PROCESS_KIND_UNSANDBOXED_NO_GL && (kind == GPU_PROCESS_KIND_INFO_COLLECTION &&
command_line->HasSwitch(switches::kGpu2StartupDialog)) || command_line->HasSwitch(switches::kGpu2StartupDialog)) ||
#endif #endif
(kind == GPU_PROCESS_KIND_SANDBOXED && (kind == GPU_PROCESS_KIND_SANDBOXED &&
command_line->HasSwitch(switches::kGpuStartupDialog)); command_line->HasSwitch(switches::kGpuStartupDialog));
#if defined(OS_WIN) #if defined(OS_WIN)
if (kind == GPU_PROCESS_KIND_UNSANDBOXED_NO_GL) { if (kind == GPU_PROCESS_KIND_INFO_COLLECTION) {
gpu_preferences->disable_gpu_watchdog = true; gpu_preferences->disable_gpu_watchdog = true;
gpu_preferences->enable_perf_data_collection = true; gpu_preferences->enable_perf_data_collection = true;
} }
......
...@@ -501,8 +501,9 @@ GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, bool force_create) { ...@@ -501,8 +501,9 @@ GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, bool force_create) {
return nullptr; return nullptr;
} }
// Do not launch the unsandboxed GPU process if GPU is disabled // Do not launch the unsandboxed GPU info collection process if GPU is
if (kind == GPU_PROCESS_KIND_UNSANDBOXED_NO_GL) { // disabled
if (kind == GPU_PROCESS_KIND_INFO_COLLECTION) {
auto* command_line = base::CommandLine::ForCurrentProcess(); auto* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableGpu) || if (command_line->HasSwitch(switches::kDisableGpu) ||
command_line->HasSwitch(switches::kSingleProcess) || command_line->HasSwitch(switches::kSingleProcess) ||
...@@ -564,7 +565,7 @@ void GpuProcessHost::CallOnIO( ...@@ -564,7 +565,7 @@ void GpuProcessHost::CallOnIO(
bool force_create, bool force_create,
base::OnceCallback<void(GpuProcessHost*)> callback) { base::OnceCallback<void(GpuProcessHost*)> callback) {
#if !defined(OS_WIN) #if !defined(OS_WIN)
DCHECK_NE(kind, GPU_PROCESS_KIND_UNSANDBOXED_NO_GL); DCHECK_NE(kind, GPU_PROCESS_KIND_INFO_COLLECTION);
#endif #endif
base::PostTask(FROM_HERE, {BrowserThread::IO}, base::PostTask(FROM_HERE, {BrowserThread::IO},
base::BindOnce(&RunCallbackOnIO, kind, force_create, base::BindOnce(&RunCallbackOnIO, kind, force_create,
...@@ -735,7 +736,7 @@ GpuProcessHost::~GpuProcessHost() { ...@@ -735,7 +736,7 @@ GpuProcessHost::~GpuProcessHost() {
message = "The GPU process "; message = "The GPU process ";
} else { } else {
message = "The unsandboxed GPU process "; message = "The info collection GPU process ";
} }
switch (info.status) { switch (info.status) {
...@@ -970,7 +971,7 @@ void GpuProcessHost::DidInitialize( ...@@ -970,7 +971,7 @@ void GpuProcessHost::DidInitialize(
"initialization time was " "initialization time was "
<< gpu_info.initialization_time.InMilliseconds() << " ms"; << gpu_info.initialization_time.InMilliseconds() << " ms";
} }
if (kind_ != GPU_PROCESS_KIND_UNSANDBOXED_NO_GL) { if (kind_ != GPU_PROCESS_KIND_INFO_COLLECTION) {
auto* gpu_data_manager = GpuDataManagerImpl::GetInstance(); auto* gpu_data_manager = GpuDataManagerImpl::GetInstance();
// Update GpuFeatureInfo first, because UpdateGpuInfo() will notify all // Update GpuFeatureInfo first, because UpdateGpuInfo() will notify all
// listeners. // listeners.
...@@ -1100,7 +1101,7 @@ bool GpuProcessHost::LaunchGpuProcess() { ...@@ -1100,7 +1101,7 @@ bool GpuProcessHost::LaunchGpuProcess() {
cmd_line->AppendArg(switches::kPrefetchArgumentGpu); cmd_line->AppendArg(switches::kPrefetchArgumentGpu);
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED_NO_GL) { if (kind_ == GPU_PROCESS_KIND_INFO_COLLECTION) {
cmd_line->AppendSwitch(service_manager::switches::kDisableGpuSandbox); cmd_line->AppendSwitch(service_manager::switches::kDisableGpuSandbox);
cmd_line->AppendSwitchASCII(switches::kUseGL, cmd_line->AppendSwitchASCII(switches::kUseGL,
gl::kGLImplementationDisabledName); gl::kGLImplementationDisabledName);
......
...@@ -25,7 +25,7 @@ struct VideoMemoryUsageStats; ...@@ -25,7 +25,7 @@ struct VideoMemoryUsageStats;
namespace content { namespace content {
enum GpuProcessKind { enum GpuProcessKind {
GPU_PROCESS_KIND_UNSANDBOXED_NO_GL, // Unsandboxed, no init GL bindings. GPU_PROCESS_KIND_INFO_COLLECTION, // Unsandboxed, no init GL bindings.
GPU_PROCESS_KIND_SANDBOXED, GPU_PROCESS_KIND_SANDBOXED,
GPU_PROCESS_KIND_COUNT GPU_PROCESS_KIND_COUNT
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment