Index: content/browser/renderer_host/render_widget_host_impl.cc |
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
index c02b51aeef383a7dec78d64262fea8961339d576..cece57a1412987df052eb9fc374f122ed6fab8f6 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -91,6 +91,10 @@ namespace { |
bool g_check_for_pending_resize_ack = true; |
+const size_t kBrowserCompositeLatencyHistorySize = 60; |
+const double kBrowserCompositeLatencyEstimationPercentile = 90.0; |
+const double kBrowserCompositeLatencyEstimationSlack = 1.1; |
+ |
typedef std::pair<int32, int32> RenderWidgetHostID; |
typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> |
RoutingIDWidgetMap; |
@@ -184,6 +188,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
allow_privileged_mouse_lock_(false), |
has_touch_handler_(false), |
next_browser_snapshot_id_(1), |
+ browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize), |
weak_factory_(this) { |
CHECK(delegate_); |
if (routing_id_ == MSG_ROUTING_NONE) { |
@@ -1438,6 +1443,9 @@ bool RenderWidgetHostImpl::OnSwapCompositorFrame( |
input_router_->OnViewUpdated( |
GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); |
+ for (auto& latency : frame->metadata.latency_info) |
+ latency.AddLatencyNumber(ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, 0, 0); |
+ |
if (view_) { |
view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); |
view_->DidReceiveRendererFrame(); |
@@ -2011,6 +2019,21 @@ void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
} |
latency_tracker_.OnFrameSwapped(latency_info); |
+ |
+ ui::LatencyInfo::LatencyComponent gpu_swap_component; |
+ if (!latency_info.FindLatency( |
+ ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, &gpu_swap_component)) { |
+ return; |
+ } |
+ |
+ ui::LatencyInfo::LatencyComponent composite_component; |
+ if (latency_info.FindLatency(ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, |
+ 0, |
+ &composite_component)) { |
+ base::TimeDelta delta = |
+ gpu_swap_component.event_time - composite_component.event_time; |
+ browser_composite_latency_history_.InsertSample(delta); |
+ } |
} |
void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
@@ -2157,6 +2180,17 @@ BrowserAccessibilityManager* |
delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
} |
+base::TimeDelta RenderWidgetHostImpl::GetEstimatedBrowserCompositeTime() { |
+ // TODO(brianderson): Remove lower bound on estimate once we're sure it won't |
+ // cause regressions. |
+ return std::max( |
+ browser_composite_latency_history_.Percentile( |
+ kBrowserCompositeLatencyEstimationPercentile) * |
+ kBrowserCompositeLatencyEstimationSlack, |
+ base::TimeDelta::FromMicroseconds( |
+ (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
+} |
+ |
#if defined(OS_WIN) |
gfx::NativeViewAccessible |
RenderWidgetHostImpl::GetParentNativeViewAccessible() { |