From b311f6aba82cd93b2d748b8e47c6f8d29a21746d Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Fri, 3 Feb 2023 11:01:52 +0000 Subject: [PATCH] Add UMA histograms to track usage of fullscreen detection Bug: chromium:1348011 Change-Id: I3219e74c49ff77e00b2224c8cf82f78d1e0fd9cf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291708 Reviewed-by: Harald Alvestrand Commit-Queue: Johannes Kron Cr-Commit-Position: refs/heads/main@{#39254} --- .../desktop_capture/cropping_window_capturer_win.cc | 7 +++++++ modules/desktop_capture/desktop_capturer.cc | 5 +++++ modules/desktop_capture/desktop_capturer.h | 2 ++ modules/desktop_capture/window_capturer_mac.mm | 12 +++++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/cropping_window_capturer_win.cc b/modules/desktop_capture/cropping_window_capturer_win.cc index 64d9219e24..5d99cb6b2b 100644 --- a/modules/desktop_capture/cropping_window_capturer_win.cc +++ b/modules/desktop_capture/cropping_window_capturer_win.cc @@ -153,6 +153,9 @@ class CroppingWindowCapturerWin : public CroppingWindowCapturer { bool enumerate_current_process_windows_; rtc::scoped_refptr full_screen_window_detector_; + + // Used to make sure that we only log the usage of fullscreen detection once. + mutable bool fullscreen_usage_logged_ = false; }; void CroppingWindowCapturerWin::CaptureFrame() { @@ -307,6 +310,10 @@ WindowId CroppingWindowCapturerWin::GetWindowToCapture() const { full_screen_window_detector_ ? full_screen_window_detector_->FindFullScreenWindow(selected_source) : 0; + if (full_screen_source != selected_source && !fullscreen_usage_logged_) { + fullscreen_usage_logged_ = true; + LogDesktopCapturerFullscreenDetectorUsage(); + } return full_screen_source ? full_screen_source : selected_source; } diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc index dc24b387d5..c6a8dec4d4 100644 --- a/modules/desktop_capture/desktop_capturer.cc +++ b/modules/desktop_capture/desktop_capturer.cc @@ -19,6 +19,7 @@ #include "modules/desktop_capture/cropping_window_capturer.h" #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capturer_differ_wrapper.h" +#include "system_wrappers/include/metrics.h" #if defined(RTC_ENABLE_WIN_WGC) #include "modules/desktop_capture/win/wgc_capturer_win.h" @@ -27,6 +28,10 @@ namespace webrtc { +void LogDesktopCapturerFullscreenDetectorUsage() { + RTC_HISTOGRAM_BOOLEAN("WebRTC.Screenshare.DesktopCapturerUsage", true); +} + DesktopCapturer::~DesktopCapturer() = default; DelegatedSourceListController* diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h index 04991f20ea..fd884f13ff 100644 --- a/modules/desktop_capture/desktop_capturer.h +++ b/modules/desktop_capture/desktop_capturer.h @@ -32,6 +32,8 @@ namespace webrtc { +void RTC_EXPORT LogDesktopCapturerFullscreenDetectorUsage(); + class DesktopCaptureOptions; class DesktopFrame; diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm index f0b413b0a6..f99b4a74d1 100644 --- a/modules/desktop_capture/window_capturer_mac.mm +++ b/modules/desktop_capture/window_capturer_mac.mm @@ -73,6 +73,9 @@ class WindowCapturerMac : public DesktopCapturer { const rtc::scoped_refptr configuration_monitor_; WindowFinderMac window_finder_; + + // Used to make sure that we only log the usage of fullscreen detection once. + bool fullscreen_usage_logged_ = false; }; WindowCapturerMac::WindowCapturerMac( @@ -178,7 +181,14 @@ void WindowCapturerMac::CaptureFrame() { CGWindowID full_screen_window = full_screen_window_detector_->FindFullScreenWindow(window_id_); - if (full_screen_window != kCGNullWindowID) on_screen_window = full_screen_window; + if (full_screen_window != kCGNullWindowID) { + // If this is the first time this happens, report to UMA that the feature is active. + if (!fullscreen_usage_logged_) { + LogDesktopCapturerFullscreenDetectorUsage(); + fullscreen_usage_logged_ = true; + } + on_screen_window = full_screen_window; + } } std::unique_ptr frame = DesktopFrameCGImage::CreateForWindow(on_screen_window);