media: Add histograms for multi-GPU with external display on MF errors

Need to report histograms for multi-GPU where the active GPU is
associated with an external display for further investigation and
potentially disable PlayReady SL3000 playback on those devices
temporarily until we address the underlying root causes around the
high volume of unrecoverable hardware-context-reset errors.

- *.MultiGpuNvidiaActiveWithExternalDisplay: Whether or not a multi-GPU
  device has NVIDIA active GPU associated with an external displays
- *.MultiGpuWithExternalDisplay: Whether or not a multi-GPU device has
  an active GPU associated with an external displays

Bug: b:454139099, b:454691291, 467315112
Change-Id: Id8387670137e2fe17b1776d4d329bbc6bb994075
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7243770
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Sangbaek Park <sangbaekpark@chromium.org>
Reviewed-by: Evan Liu <evliu@google.com>
Auto-Submit: Sangbaek Park <sangbaekpark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1558341}
diff --git a/media/renderers/win/media_foundation_renderer.cc b/media/renderers/win/media_foundation_renderer.cc
index 2c14b092..9d289474 100644
--- a/media/renderers/win/media_foundation_renderer.cc
+++ b/media/renderers/win/media_foundation_renderer.cc
@@ -396,6 +396,27 @@
       base::UmaHistogramSparse(uma_prefix + ".NonActiveGpuVendorId",
                                nonactive_gpu_id);
     }
+
+    // On multi-gpu devices with NVIDIA active gpu associated with an external
+    // display
+    const auto multigpu_nvidia_active_with_external =
+        nonactive_gpu_count > 0 && active_gpu_vendor_id == kGpuVendorIdNvidia &&
+        active_gpu_display_info == ActiveGpuDisplayInfo::kLikelyExternal;
+    DVLOG(3) << __func__ << ": multigpu_nvidia_active_with_external="
+             << multigpu_nvidia_active_with_external;
+    base::UmaHistogramBoolean(
+        uma_prefix + ".MultiGpuNvidiaActiveWithExternalDisplay",
+        multigpu_nvidia_active_with_external);
+
+    // On multi-gpu devices where the active gpu associated with an external
+    // display
+    const auto multigpu_with_external =
+        nonactive_gpu_count > 0 &&
+        active_gpu_display_info == ActiveGpuDisplayInfo::kLikelyExternal;
+    DVLOG(3) << __func__
+             << ": multigpu_with_external=" << multigpu_with_external;
+    base::UmaHistogramBoolean(uma_prefix + ".MultiGpuWithExternalDisplay",
+                              multigpu_with_external);
   }
 
   const auto display_count = GetTotalDisplayCount();
diff --git a/tools/metrics/histograms/metadata/media/histograms.xml b/tools/metrics/histograms/metadata/media/histograms.xml
index a14f538..a54c933 100644
--- a/tools/metrics/histograms/metadata/media/histograms.xml
+++ b/tools/metrics/histograms/metadata/media/histograms.xml
@@ -3893,6 +3893,30 @@
 </histogram>
 
 <histogram
+    name="Media.EME.MediaFoundationService.HardwareContextReset.MultiGpuNvidiaActiveWithExternalDisplay"
+    enum="GpuVendorId" expires_after="2026-04-05">
+  <owner>sangbaekpark@chromium.org</owner>
+  <owner>media-dev-uma@chromium.org</owner>
+  <summary>
+    Whether or not a multi-GPU device has NVIDIA active GPU associated with an
+    external displays when a HardwareContextReset event happened in the
+    MediaFoundationService process. Reported whenever such an event happens.
+  </summary>
+</histogram>
+
+<histogram
+    name="Media.EME.MediaFoundationService.HardwareContextReset.MultiGpuWithExternalDisplay"
+    enum="GpuVendorId" expires_after="2026-04-05">
+  <owner>sangbaekpark@chromium.org</owner>
+  <owner>media-dev-uma@chromium.org</owner>
+  <summary>
+    Whether or not a multi-GPU device has an active GPU associated with an
+    external displays when a HardwareContextReset event happened in the
+    MediaFoundationService process. Reported whenever such an event happens.
+  </summary>
+</histogram>
+
+<histogram
     name="Media.EME.MediaFoundationService.HardwareContextReset.NonActiveGpuVendorId"
     enum="GpuVendorId" expires_after="2026-12-09">
   <owner>sangbaekpark@chromium.org</owner>
@@ -5286,6 +5310,30 @@
 </histogram>
 
 <histogram
+    name="Media.MediaFoundationRenderer.PlaybackError.MultiGpuNvidiaActiveWithExternalDisplay"
+    enum="GpuVendorId" expires_after="2026-04-05">
+  <owner>sangbaekpark@chromium.org</owner>
+  <owner>media-dev-uma@chromium.org</owner>
+  <summary>
+    Whether or not a multi-GPU device has NVIDIA active GPU associated with an
+    external displays when the MediaFoundationRenderer hits a playback error.
+    Reported whenever such an event happens.
+  </summary>
+</histogram>
+
+<histogram
+    name="Media.MediaFoundationRenderer.PlaybackError.MultiGpuWithExternalDisplay"
+    enum="GpuVendorId" expires_after="2026-04-05">
+  <owner>sangbaekpark@chromium.org</owner>
+  <owner>media-dev-uma@chromium.org</owner>
+  <summary>
+    Whether or not a multi-GPU device has an active GPU associated with an
+    external displays when the MediaFoundationRenderer hits a playback error.
+    Reported whenever such an event happens.
+  </summary>
+</histogram>
+
+<histogram
     name="Media.MediaFoundationRenderer.PlaybackError.NonActiveGpuVendorId"
     enum="GpuVendorId" expires_after="2026-12-09">
   <owner>sangbaekpark@chromium.org</owner>