Commit 68185c7d authored by Lu Chen's avatar Lu Chen Committed by Commit Bot

Fix overflow issue in blink::AnchorElementMetrics::RecordMetrics.

Detail: In order to get finer resolution when recording metrics,
the program multiples the area/distance metrics by 100 before sending
to UMA, which can cause overflow.

Fix: For area metric, the result is limited to 1.0; for distance
metric, the result is limited to the maximum expected value (10000)
by UMA before sending.

Bug: 853435
Change-Id: Ie8d9751c86bd64f38bd79c3e12d502f71a551522
Reviewed-on: https://chromium-review.googlesource.com/1105506
Commit-Queue: Lu Chen <chelu@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569390}
parent 5f173cb1
......@@ -63,7 +63,9 @@ base::Optional<AnchorElementMetrics> AnchorElementMetrics::From(
target_location = local_frame_view->ConvertToRootFrame(target_location);
// Calculate features of the anchor element.
float ratio_area = FloatSize(target_rect.Size()).Area() / visible_size.Area();
// Limit the element size to the viewport size.
float ratio_area = std::min(
1.0f, FloatSize(target_rect.Size()).Area() / visible_size.Area());
float ratio_distance_root_top =
float(target_location.Y() +
AccumulatedScrollOffset(anchor_element).Height()) /
......@@ -82,11 +84,11 @@ void AnchorElementMetrics::RecordMetrics() const {
UMA_HISTOGRAM_COUNTS_10000(
"AnchorElementMetrics.Clicked.RatioDistanceRootTop",
int(ratio_distance_root_top * 100));
int(std::min(ratio_distance_root_top, 100.0f) * 100));
UMA_HISTOGRAM_PERCENTAGE(
UMA_HISTOGRAM_COUNTS_10000(
"AnchorElementMetrics.Clicked.RatioDistanceVisibleTop",
int(ratio_distance_visible_top * 100));
int(std::min(ratio_distance_visible_top, 100.0f) * 100));
UMA_HISTOGRAM_BOOLEAN("AnchorElementMetrics.Clicked.IsInIFrame",
is_in_iframe);
......
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