Change UMA logging to only log once for same kind of error `FullScreenPowerPointHandler::FindEditorWindow()` was previously recording `FullScreenFindEditorResult` UMA metrics on every frame. This causes log spam, especially when the heuristic fails due to multiple editors having the same title. This CL caches the previous result in `previous_find_editor_result_` and only records the metric when the result differs from the previous call. Bug: chromium:409473386 Change-Id: I44500864c89dd7415327c91778086ecd667cdd15 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/458041 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Palak Agarwal <agpalak@google.com> Cr-Commit-Position: refs/heads/main@{#47193}
diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.cc b/modules/desktop_capture/win/full_screen_win_application_handler.cc index c7548b0..7a245c9 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.cc +++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc
@@ -36,10 +36,16 @@ static_cast<int>(FullScreenDetectorResult::kMaxValue)); } -void RecordFullScreenFindEditorResult(FullScreenFindEditorResult result) { - RTC_HISTOGRAM_ENUMERATION( - "WebRTC.Screenshare.FullScreenFindEditorResult", static_cast<int>(result), - static_cast<int>(FullScreenFindEditorResult::kMaxValue)); +void MaybeRecordFullScreenFindEditorResult( + FullScreenFindEditorResult result, + std::optional<FullScreenFindEditorResult>& previous_result) { + if (previous_result != result) { + RTC_HISTOGRAM_ENUMERATION( + "WebRTC.Screenshare.FullScreenFindEditorResult", + static_cast<int>(result), + static_cast<int>(FullScreenFindEditorResult::kMaxValue)); + previous_result = result; + } } namespace webrtc { @@ -246,15 +252,17 @@ } if (editor_ids.size() != 1) { - RecordFullScreenFindEditorResult( - FullScreenFindEditorResult::kFailureDueToSameTitleWindows); + MaybeRecordFullScreenFindEditorResult( + FullScreenFindEditorResult::kFailureDueToSameTitleWindows, + previous_find_editor_result_); // If `editor_ids` has more than one id, then there are multiple open // editors with the same title as the full screen slide show and then // there's no way of knowing which editor has opened the slide show. return 0; } - RecordFullScreenFindEditorResult(FullScreenFindEditorResult::kSuccess); + MaybeRecordFullScreenFindEditorResult(FullScreenFindEditorResult::kSuccess, + previous_find_editor_result_); return *editor_ids.begin(); }
diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.h b/modules/desktop_capture/win/full_screen_win_application_handler.h index 0accd62..3a51cea 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.h +++ b/modules/desktop_capture/win/full_screen_win_application_handler.h
@@ -15,6 +15,7 @@ #include <cstdint> #include <memory> +#include <optional> #include <string> #include "modules/desktop_capture/desktop_capturer.h" @@ -82,6 +83,9 @@ mutable bool was_slide_show_created_after_capture_started_; mutable FullScreenDetectorResult full_screen_detector_result_; + + mutable std::optional<FullScreenFindEditorResult> + previous_find_editor_result_; }; std::unique_ptr<FullScreenApplicationHandler>