fix_revert_windows_collect_gpu_memory.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Keeley Hammond <[email protected]>
  3. Date: Tue, 12 Mar 2024 12:26:56 -0700
  4. Subject: fix: revert "Collect GPU memory on GPU process start on Windows"
  5. This patch reverts a CL that we believe is causing Electron crashes within GetWmiPerferredMonitorSourceMode. Reviewing the CL history, it seems as though this change has been reverted and relanded several times, and is suspected of causing a crash. This patch can be removed when the cause of the crash is either fixed upstream or pinpointed within Electron itself.
  6. This reverts commit a10ac33565e0e7ada7f828d52be8837a67b304f3.
  7. diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc
  8. index 3306a36044eed8395b3a13cffa4754cadee1048d..a202d834a42d66b8a3aa66560e7b1d5dc06a51b1 100644
  9. --- a/content/browser/gpu/gpu_data_manager_impl_private.cc
  10. +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
  11. @@ -487,26 +487,6 @@ class HDRProxy {
  12. }
  13. };
  14. -int GetMaxMemory(const gpu::DxDiagNode& node) {
  15. - int memory = 0;
  16. - auto it = node.values.find("szDisplayMemoryEnglish");
  17. - if (it != node.values.end()) {
  18. - base::StringToInt(it->second, &memory);
  19. - }
  20. -
  21. - for (const auto& child : node.children) {
  22. - memory = std::max(memory, GetMaxMemory(child.second));
  23. - }
  24. - return memory;
  25. -}
  26. -
  27. -void RecordDxDiagNodeHistograms(const gpu::DxDiagNode& dx_diagnostics) {
  28. - int gpu_memory = GetMaxMemory(dx_diagnostics);
  29. - if (gpu_memory != 0) {
  30. - base::UmaHistogramMemoryLargeMB("GPU.Memory.Device", gpu_memory);
  31. - }
  32. -}
  33. -
  34. #endif // BUILDFLAG(IS_WIN)
  35. } // anonymous namespace
  36. @@ -668,7 +648,9 @@ void GpuDataManagerImplPrivate::RequestDxdiagDx12VulkanVideoGpuInfoIfNeeded(
  37. GpuDataManagerImpl::GpuInfoRequest request,
  38. bool delayed) {
  39. if (request & GpuDataManagerImpl::kGpuInfoRequestDxDiag) {
  40. - RequestDxDiagNodeData(delayed);
  41. + // Delay is not supported in DxDiag request
  42. + DCHECK(!delayed);
  43. + RequestDxDiagNodeData();
  44. }
  45. if (request & GpuDataManagerImpl::kGpuInfoRequestDx12)
  46. @@ -686,14 +668,11 @@ void GpuDataManagerImplPrivate::RequestDxdiagDx12VulkanVideoGpuInfoIfNeeded(
  47. }
  48. }
  49. -void GpuDataManagerImplPrivate::RequestDxDiagNodeData(bool delayed) {
  50. +void GpuDataManagerImplPrivate::RequestDxDiagNodeData() {
  51. #if BUILDFLAG(IS_WIN)
  52. - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  53. - base::TimeDelta delta;
  54. - if (delayed &&
  55. - !command_line->HasSwitch(switches::kNoDelayForDX12VulkanInfoCollection)) {
  56. - delta = base::Seconds(120);
  57. - }
  58. + if (gpu_info_dx_diag_requested_)
  59. + return;
  60. + gpu_info_dx_diag_requested_ = true;
  61. base::OnceClosure task = base::BindOnce([]() {
  62. GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
  63. @@ -722,11 +701,10 @@ void GpuDataManagerImplPrivate::RequestDxDiagNodeData(bool delayed) {
  64. GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
  65. manager->UpdateDxDiagNode(dx_diagnostics);
  66. manager->TerminateInfoCollectionGpuProcess();
  67. - RecordDxDiagNodeHistograms(dx_diagnostics);
  68. }));
  69. });
  70. - GetUIThreadTaskRunner({})->PostDelayedTask(FROM_HERE, std::move(task), delta);
  71. + GetUIThreadTaskRunner({})->PostTask(FROM_HERE, std::move(task));
  72. #endif
  73. }
  74. @@ -1163,7 +1141,6 @@ void GpuDataManagerImplPrivate::UpdateDXGIInfo(
  75. void GpuDataManagerImplPrivate::UpdateDxDiagNodeRequestStatus(
  76. bool request_continues) {
  77. - gpu_info_dx_diag_requested_ = true;
  78. gpu_info_dx_diag_request_failed_ = !request_continues;
  79. if (gpu_info_dx_diag_request_failed_)
  80. @@ -1244,21 +1221,13 @@ void GpuDataManagerImplPrivate::PostCreateThreads() {
  81. GpuDataManagerImpl::kGpuInfoRequestDx12Vulkan,
  82. /*delayed=*/false);
  83. } else {
  84. - GpuDataManagerImpl::GpuInfoRequest request =
  85. - GpuDataManagerImpl::kGpuInfoRequestDx12;
  86. -
  87. - static BASE_FEATURE(kCollectGpuMemoryMetrics, "CollectGpuMemoryMetrics",
  88. - base::FEATURE_ENABLED_BY_DEFAULT);
  89. - if (base::FeatureList::IsEnabled(kCollectGpuMemoryMetrics)) {
  90. - request = static_cast<GpuDataManagerImpl::GpuInfoRequest>(
  91. - request | GpuDataManagerImpl::kGpuInfoRequestDxDiag);
  92. - }
  93. -
  94. // Launch the info collection GPU process to collect DX12 support
  95. // information for UMA at the start of the browser.
  96. // Not to affect Chrome startup, this is done in a delayed mode, i.e., 120
  97. // seconds after Chrome startup.
  98. - RequestDxdiagDx12VulkanVideoGpuInfoIfNeeded(request, /*delayed=*/true);
  99. + RequestDxdiagDx12VulkanVideoGpuInfoIfNeeded(
  100. + GpuDataManagerImpl::kGpuInfoRequestDx12,
  101. + /*delayed=*/true);
  102. }
  103. // Observer for display change.
  104. @@ -1540,7 +1509,7 @@ void GpuDataManagerImplPrivate::OnDisplayAdded(
  105. gpu_info_.dx_diagnostics = gpu::DxDiagNode();
  106. // This DxDiag request goes to the unsandboxed GPU info collection GPU
  107. // process while the notification below goes to the sandboxed GPU process.
  108. - RequestDxDiagNodeData(/*delayed=*/false);
  109. + RequestDxDiagNodeData();
  110. }
  111. #endif
  112. @@ -1566,7 +1535,7 @@ void GpuDataManagerImplPrivate::OnDisplayRemoved(
  113. gpu_info_.dx_diagnostics = gpu::DxDiagNode();
  114. // This DxDiag request goes to the unsandboxed GPU info collection GPU
  115. // process while the notification below goes to the sandboxed GPU process.
  116. - RequestDxDiagNodeData(/*delayed=*/false);
  117. + RequestDxDiagNodeData();
  118. }
  119. #endif
  120. @@ -1593,7 +1562,7 @@ void GpuDataManagerImplPrivate::OnDisplayMetricsChanged(
  121. gpu_info_.dx_diagnostics = gpu::DxDiagNode();
  122. // This DxDiag request goes to the unsandboxed GPU info collection GPU
  123. // process while the notification below goes to the sandboxed GPU process.
  124. - RequestDxDiagNodeData(/*delayed=*/false);
  125. + RequestDxDiagNodeData();
  126. }
  127. #endif
  128. diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h
  129. index 28306624ec6f7f9a7848e65787d4dc5aa738a76c..290a948e28c8123bc47f91f0e77acbce759b6989 100644
  130. --- a/content/browser/gpu/gpu_data_manager_impl_private.h
  131. +++ b/content/browser/gpu/gpu_data_manager_impl_private.h
  132. @@ -232,7 +232,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
  133. // Notify all observers whenever there is a GPU info update.
  134. void NotifyGpuInfoUpdate();
  135. - void RequestDxDiagNodeData(bool delayed);
  136. + void RequestDxDiagNodeData();
  137. void RequestGpuSupportedDx12Version(bool delayed);
  138. void RequestGpuSupportedVulkanVersion(bool delayed);
  139. void RequestDawnInfo(bool delayed, bool collect_metrics);