diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/latency | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/latency')
-rw-r--r-- | chromium/ui/latency/average_lag_tracker.cc | 153 | ||||
-rw-r--r-- | chromium/ui/latency/average_lag_tracker.h | 6 | ||||
-rw-r--r-- | chromium/ui/latency/latency_info.cc | 1 | ||||
-rw-r--r-- | chromium/ui/latency/latency_tracker.cc | 14 | ||||
-rw-r--r-- | chromium/ui/latency/latency_tracker.h | 11 | ||||
-rw-r--r-- | chromium/ui/latency/mojom/BUILD.gn | 22 | ||||
-rw-r--r-- | chromium/ui/latency/mojom/latency_info_mojom_traits.h | 10 |
7 files changed, 119 insertions, 98 deletions
diff --git a/chromium/ui/latency/average_lag_tracker.cc b/chromium/ui/latency/average_lag_tracker.cc index 4c8c7ef82b0..347b32d3050 100644 --- a/chromium/ui/latency/average_lag_tracker.cc +++ b/chromium/ui/latency/average_lag_tracker.cc @@ -26,78 +26,10 @@ void AverageLagTracker::AddLatencyInFrame( return; if (scroll_name == "ScrollBegin") { - // Flush all unfinished frames. - while (!frame_lag_infos_.empty()) { - frame_lag_infos_.front().lag_area += LagForUnfinishedFrame( - frame_lag_infos_.front().rendered_accumulated_delta); - frame_lag_infos_.front().lag_area_no_prediction += LagForUnfinishedFrame( - frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); - - // Record UMA when it's the last item in queue. - CalculateAndReportAverageLagUma(frame_lag_infos_.size() == 1); - } - // |accumulated_lag_| should be cleared/reset. - DCHECK(accumulated_lag_ == 0); - - // Create ScrollBegin report, with report time equals to gpu swap time. - LagAreaInFrame first_frame(gpu_swap_begin_timestamp); - frame_lag_infos_.push_back(first_frame); - - // Reset fields. - last_reported_time_ = event_timestamp; - last_finished_frame_time_ = event_timestamp; - last_event_accumulated_delta_ = 0; - last_rendered_accumulated_delta_ = 0; - is_begin_ = true; + AddScrollBeginInFrame(gpu_swap_begin_timestamp, event_timestamp); } else if (scroll_name == "ScrollUpdate" && !last_event_timestamp_.is_null()) { - // Only accept events in nondecreasing order. - if ((event_timestamp - last_event_timestamp_).InMilliseconds() < 0) - return; - - // Pop all frames where frame_time <= event_timestamp. - while (!frame_lag_infos_.empty() && - frame_lag_infos_.front().frame_time <= event_timestamp) { - base::TimeTicks front_time = - std::max(last_event_timestamp_, last_finished_frame_time_); - base::TimeTicks back_time = frame_lag_infos_.front().frame_time; - frame_lag_infos_.front().lag_area += - LagBetween(front_time, back_time, latency, event_timestamp, - frame_lag_infos_.front().rendered_accumulated_delta); - frame_lag_infos_.front().lag_area_no_prediction += LagBetween( - front_time, back_time, latency, event_timestamp, - frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); - - CalculateAndReportAverageLagUma(); - } - - // Initialize a new LagAreaInFrame when current_frame_time > frame_time. - if (frame_lag_infos_.empty() || - gpu_swap_begin_timestamp > frame_lag_infos_.back().frame_time) { - LagAreaInFrame new_frame(gpu_swap_begin_timestamp, - last_rendered_accumulated_delta_, - last_event_accumulated_delta_); - frame_lag_infos_.push_back(new_frame); - } - - // last_frame_time <= event_timestamp < frame_time - if (!frame_lag_infos_.empty()) { - // The front element in queue (if any) must satisfy frame_time > - // event_timestamp, otherwise it would be popped in the while loop. - DCHECK(last_finished_frame_time_ <= event_timestamp && - event_timestamp <= frame_lag_infos_.front().frame_time); - base::TimeTicks front_time = - std::max(last_finished_frame_time_, last_event_timestamp_); - base::TimeTicks back_time = event_timestamp; - - frame_lag_infos_.front().lag_area += - LagBetween(front_time, back_time, latency, event_timestamp, - frame_lag_infos_.front().rendered_accumulated_delta); - - frame_lag_infos_.front().lag_area_no_prediction += LagBetween( - front_time, back_time, latency, event_timestamp, - frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); - } + AddScrollUpdateInFrame(latency, gpu_swap_begin_timestamp, event_timestamp); } last_event_timestamp_ = event_timestamp; @@ -105,6 +37,87 @@ void AverageLagTracker::AddLatencyInFrame( last_rendered_accumulated_delta_ += latency.predicted_scroll_update_delta(); } +void AverageLagTracker::AddScrollBeginInFrame( + base::TimeTicks gpu_swap_begin_timestamp, + base::TimeTicks event_timestamp) { + // Flush all unfinished frames. + while (!frame_lag_infos_.empty()) { + frame_lag_infos_.front().lag_area += LagForUnfinishedFrame( + frame_lag_infos_.front().rendered_accumulated_delta); + frame_lag_infos_.front().lag_area_no_prediction += LagForUnfinishedFrame( + frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); + + // Record UMA when it's the last item in queue. + CalculateAndReportAverageLagUma(frame_lag_infos_.size() == 1); + } + // |accumulated_lag_| should be cleared/reset. + DCHECK(accumulated_lag_ == 0); + + // Create ScrollBegin report, with report time equals to gpu swap time. + LagAreaInFrame first_frame(gpu_swap_begin_timestamp); + frame_lag_infos_.push_back(first_frame); + + // Reset fields. + last_reported_time_ = event_timestamp; + last_finished_frame_time_ = event_timestamp; + last_event_accumulated_delta_ = 0; + last_rendered_accumulated_delta_ = 0; + is_begin_ = true; +} + +void AverageLagTracker::AddScrollUpdateInFrame( + const LatencyInfo& latency, + base::TimeTicks gpu_swap_begin_timestamp, + base::TimeTicks event_timestamp) { + // Only accept events in nondecreasing order. + if ((event_timestamp - last_event_timestamp_).InMilliseconds() < 0) + return; + + // Pop all frames where frame_time <= event_timestamp. + while (!frame_lag_infos_.empty() && + frame_lag_infos_.front().frame_time <= event_timestamp) { + base::TimeTicks front_time = + std::max(last_event_timestamp_, last_finished_frame_time_); + base::TimeTicks back_time = frame_lag_infos_.front().frame_time; + frame_lag_infos_.front().lag_area += + LagBetween(front_time, back_time, latency, event_timestamp, + frame_lag_infos_.front().rendered_accumulated_delta); + frame_lag_infos_.front().lag_area_no_prediction += LagBetween( + front_time, back_time, latency, event_timestamp, + frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); + + CalculateAndReportAverageLagUma(); + } + + // Initialize a new LagAreaInFrame when current_frame_time > frame_time. + if (frame_lag_infos_.empty() || + gpu_swap_begin_timestamp > frame_lag_infos_.back().frame_time) { + LagAreaInFrame new_frame(gpu_swap_begin_timestamp, + last_rendered_accumulated_delta_, + last_event_accumulated_delta_); + frame_lag_infos_.push_back(new_frame); + } + + // last_frame_time <= event_timestamp < frame_time + if (!frame_lag_infos_.empty()) { + // The front element in queue (if any) must satisfy frame_time > + // event_timestamp, otherwise it would be popped in the while loop. + DCHECK(last_finished_frame_time_ <= event_timestamp && + event_timestamp <= frame_lag_infos_.front().frame_time); + base::TimeTicks front_time = + std::max(last_finished_frame_time_, last_event_timestamp_); + base::TimeTicks back_time = event_timestamp; + + frame_lag_infos_.front().lag_area += + LagBetween(front_time, back_time, latency, event_timestamp, + frame_lag_infos_.front().rendered_accumulated_delta); + + frame_lag_infos_.front().lag_area_no_prediction += LagBetween( + front_time, back_time, latency, event_timestamp, + frame_lag_infos_.front().rendered_accumulated_delta_no_prediction); + } +} + float AverageLagTracker::LagBetween(base::TimeTicks front_time, base::TimeTicks back_time, const LatencyInfo& latency, diff --git a/chromium/ui/latency/average_lag_tracker.h b/chromium/ui/latency/average_lag_tracker.h index 80244d90233..f97738f17cf 100644 --- a/chromium/ui/latency/average_lag_tracker.h +++ b/chromium/ui/latency/average_lag_tracker.h @@ -50,6 +50,12 @@ class AverageLagTracker { float lag_area_no_prediction; } LagAreaInFrame; + void AddScrollBeginInFrame(base::TimeTicks gpu_swap_begin_timestamp, + base::TimeTicks event_timestamp); + void AddScrollUpdateInFrame(const LatencyInfo& latency, + base::TimeTicks gpu_swap_begin_timestamp, + base::TimeTicks event_timestamp); + // Calculate lag in 1 seconds intervals and report UMA. void CalculateAndReportAverageLagUma(bool send_anyway = false); diff --git a/chromium/ui/latency/latency_info.cc b/chromium/ui/latency/latency_info.cc index 8be273a5529..f369ec6df9f 100644 --- a/chromium/ui/latency/latency_info.cc +++ b/chromium/ui/latency/latency_info.cc @@ -12,6 +12,7 @@ #include "base/json/json_writer.h" #include "base/lazy_instance.h" +#include "base/logging.h" #include "base/macros.h" #include "base/strings/stringprintf.h" #include "base/trace_event/trace_event.h" diff --git a/chromium/ui/latency/latency_tracker.cc b/chromium/ui/latency/latency_tracker.cc index 0a0eb4b4c5b..a724b21d32e 100644 --- a/chromium/ui/latency/latency_tracker.cc +++ b/chromium/ui/latency/latency_tracker.cc @@ -63,11 +63,6 @@ void RecordUmaEventLatencyScrollWheelTimeToScrollUpdateSwapBegin2Histogram( 1000000, 100); } -LatencyTracker::LatencyInfoProcessor& GetLatencyInfoProcessor() { - static base::NoDestructor<LatencyTracker::LatencyInfoProcessor> processor; - return *processor; -} - bool LatencyTraceIdCompare(const LatencyInfo& i, const LatencyInfo& j) { return i.trace_id() < j.trace_id(); } @@ -80,9 +75,6 @@ LatencyTracker::~LatencyTracker() = default; void LatencyTracker::OnGpuSwapBuffersCompleted( const std::vector<ui::LatencyInfo>& latency_info, bool top_controls_visible_height_changed) { - auto& callback = GetLatencyInfoProcessor(); - if (!callback.is_null()) - callback.Run(latency_info); // Sort latency_info as they can be in incorrect order. std::vector<ui::LatencyInfo> latency_infos(latency_info); std::sort(latency_infos.begin(), latency_infos.end(), LatencyTraceIdCompare); @@ -391,10 +383,4 @@ void LatencyTracker::ComputeEndToEndLatencyHistograms( gpu_swap_begin_timestamp, gpu_swap_end_timestamp); } -// static -void LatencyTracker::SetLatencyInfoProcessorForTesting( - const LatencyInfoProcessor& processor) { - GetLatencyInfoProcessor() = processor; -} - } // namespace ui diff --git a/chromium/ui/latency/latency_tracker.h b/chromium/ui/latency/latency_tracker.h index cb3898ba5d5..e0bb699a1f3 100644 --- a/chromium/ui/latency/latency_tracker.h +++ b/chromium/ui/latency/latency_tracker.h @@ -25,14 +25,6 @@ class LatencyTracker { void OnGpuSwapBuffersCompleted( const std::vector<LatencyInfo>& latency_info, bool top_controls_visible_height_changed = false); - void OnGpuSwapBuffersCompleted( - const LatencyInfo& latency, - bool top_controls_visible_height_changed = false); - - using LatencyInfoProcessor = - base::RepeatingCallback<void(const std::vector<ui::LatencyInfo>&)>; - static void SetLatencyInfoProcessorForTesting( - const LatencyInfoProcessor& processor); private: enum class InputMetricEvent { @@ -44,6 +36,9 @@ class LatencyTracker { INPUT_METRIC_EVENT_MAX = SCROLL_UPDATE_WHEEL }; + void OnGpuSwapBuffersCompleted(const LatencyInfo& latency, + bool top_controls_visible_height_changed); + void ReportUkmScrollLatency( const InputMetricEvent& metric_event, base::TimeTicks start_timestamp, diff --git a/chromium/ui/latency/mojom/BUILD.gn b/chromium/ui/latency/mojom/BUILD.gn index f8aeb4c757e..e829e4c5281 100644 --- a/chromium/ui/latency/mojom/BUILD.gn +++ b/chromium/ui/latency/mojom/BUILD.gn @@ -4,6 +4,20 @@ import("//mojo/public/tools/bindings/mojom.gni") +component("shared_mojom_traits") { + output_name = "latency_shared_mojom_traits" + defines = [ "IS_LATENCY_SHARED_MOJOM_TRAITS_IMPL" ] + sources = [ + "latency_info_mojom_traits.cc", + "latency_info_mojom_traits.h", + ] + public_deps = [ + ":mojom_shared", + "//ipc:param_traits", + "//ui/latency", + ] +} + mojom("mojom") { generate_java = true sources = [ "latency_info.mojom" ] @@ -22,12 +36,14 @@ mojom("mojom") { cpp = "::ui::LatencyInfo" }, ] - traits_sources = [ "latency_info_mojom_traits.cc" ] traits_headers = [ "latency_info_mojom_traits.h" ] - traits_public_deps = [ "//ui/latency" ] - traits_deps = [ "//ipc:param_traits" ] + traits_public_deps = [ + ":shared_mojom_traits", + "//ui/latency", + ] }, ] + blink_cpp_typemaps = cpp_typemaps } mojom("test_interfaces") { diff --git a/chromium/ui/latency/mojom/latency_info_mojom_traits.h b/chromium/ui/latency/mojom/latency_info_mojom_traits.h index 5bc2a683060..bde8c125520 100644 --- a/chromium/ui/latency/mojom/latency_info_mojom_traits.h +++ b/chromium/ui/latency/mojom/latency_info_mojom_traits.h @@ -5,6 +5,7 @@ #ifndef UI_LATENCY_MOJOM_LATENCY_INFO_MOJOM_TRAITS_H_ #define UI_LATENCY_MOJOM_LATENCY_INFO_MOJOM_TRAITS_H_ +#include "base/component_export.h" #include "ui/latency/latency_info.h" #include "ui/latency/mojom/latency_info.mojom-shared.h" @@ -19,7 +20,8 @@ static_assert(static_cast<int>(ui::mojom::SourceEventType::kMaxValue) == "Enum size mismatch"); template <> -struct ArrayTraits<ui::LatencyInfo::LatencyMap> { +struct COMPONENT_EXPORT(LATENCY_SHARED_MOJOM_TRAITS) + ArrayTraits<ui::LatencyInfo::LatencyMap> { using Element = ui::LatencyInfo::LatencyMap::value_type; using Iterator = ui::LatencyInfo::LatencyMap::iterator; using ConstIterator = ui::LatencyInfo::LatencyMap::const_iterator; @@ -43,7 +45,8 @@ struct ArrayTraits<ui::LatencyInfo::LatencyMap> { }; template <> -struct StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> { +struct COMPONENT_EXPORT(LATENCY_SHARED_MOJOM_TRAITS) + StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> { static const ui::LatencyInfo::LatencyMap& latency_components( const ui::LatencyInfo& info); static int64_t trace_id(const ui::LatencyInfo& info); @@ -60,7 +63,8 @@ struct StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> { }; template <> -struct EnumTraits<ui::mojom::LatencyComponentType, ui::LatencyComponentType> { +struct COMPONENT_EXPORT(LATENCY_SHARED_MOJOM_TRAITS) + EnumTraits<ui::mojom::LatencyComponentType, ui::LatencyComponentType> { static ui::mojom::LatencyComponentType ToMojom(ui::LatencyComponentType type); static bool FromMojom(ui::mojom::LatencyComponentType input, ui::LatencyComponentType* output); |