Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 577273003: Add new latency_info for tracking browser composite time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename and add id's to components Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 using blink::WebKeyboardEvent; 82 using blink::WebKeyboardEvent;
83 using blink::WebMouseEvent; 83 using blink::WebMouseEvent;
84 using blink::WebMouseWheelEvent; 84 using blink::WebMouseWheelEvent;
85 using blink::WebTextDirection; 85 using blink::WebTextDirection;
86 86
87 namespace content { 87 namespace content {
88 namespace { 88 namespace {
89 89
90 bool g_check_for_pending_resize_ack = true; 90 bool g_check_for_pending_resize_ack = true;
91 91
92 const size_t kBrowserCompositeLatencyHistorySize = 60;
93 const double kBrowserCompositeLatencyEstimationPercentile = 90.0;
94
92 typedef std::pair<int32, int32> RenderWidgetHostID; 95 typedef std::pair<int32, int32> RenderWidgetHostID;
93 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> 96 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>
94 RoutingIDWidgetMap; 97 RoutingIDWidgetMap;
95 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = 98 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map =
96 LAZY_INSTANCE_INITIALIZER; 99 LAZY_INSTANCE_INITIALIZER;
97 100
98 int GetInputRouterViewFlagsFromCompositorFrameMetadata( 101 int GetInputRouterViewFlagsFromCompositorFrameMetadata(
99 const cc::CompositorFrameMetadata metadata) { 102 const cc::CompositorFrameMetadata metadata) {
100 int view_flags = InputRouter::VIEW_FLAGS_NONE; 103 int view_flags = InputRouter::VIEW_FLAGS_NONE;
101 104
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 input_method_active_(false), 182 input_method_active_(false),
180 text_direction_updated_(false), 183 text_direction_updated_(false),
181 text_direction_(blink::WebTextDirectionLeftToRight), 184 text_direction_(blink::WebTextDirectionLeftToRight),
182 text_direction_canceled_(false), 185 text_direction_canceled_(false),
183 suppress_next_char_events_(false), 186 suppress_next_char_events_(false),
184 pending_mouse_lock_request_(false), 187 pending_mouse_lock_request_(false),
185 allow_privileged_mouse_lock_(false), 188 allow_privileged_mouse_lock_(false),
186 has_touch_handler_(false), 189 has_touch_handler_(false),
187 weak_factory_(this), 190 weak_factory_(this),
188 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), 191 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32),
189 next_browser_snapshot_id_(1) { 192 next_browser_snapshot_id_(1),
193 browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize) {
190 CHECK(delegate_); 194 CHECK(delegate_);
191 if (routing_id_ == MSG_ROUTING_NONE) { 195 if (routing_id_ == MSG_ROUTING_NONE) {
192 routing_id_ = process_->GetNextRoutingID(); 196 routing_id_ = process_->GetNextRoutingID();
193 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( 197 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer(
194 process_->GetID(), 198 process_->GetID(),
195 routing_id_); 199 routing_id_);
196 } else { 200 } else {
197 // TODO(piman): This is a O(N) lookup, where we could forward the 201 // TODO(piman): This is a O(N) lookup, where we could forward the
198 // information from the RenderWidgetHelper. The problem is that doing so 202 // information from the RenderWidgetHelper. The problem is that doing so
199 // currently leaks outside of content all the way to chrome classes, and 203 // currently leaks outside of content all the way to chrome classes, and
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 param.b.AssignTo(frame.get()); 1448 param.b.AssignTo(frame.get());
1445 std::vector<IPC::Message> messages_to_deliver_with_frame; 1449 std::vector<IPC::Message> messages_to_deliver_with_frame;
1446 messages_to_deliver_with_frame.swap(param.c); 1450 messages_to_deliver_with_frame.swap(param.c);
1447 1451
1448 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) 1452 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++)
1449 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]); 1453 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]);
1450 1454
1451 input_router_->OnViewUpdated( 1455 input_router_->OnViewUpdated(
1452 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); 1456 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata));
1453 1457
1458 for (size_t i = 0; i < frame->metadata.latency_info.size(); ++i) {
1459 frame->metadata.latency_info[i].AddLatencyNumber(
1460 ui::INPUT_EVENT_RENDERER_SWAP_RECEIVED_COMPONENT,
1461 GetLatencyComponentId(),
1462 0);
1463 }
1464
1454 if (view_) { 1465 if (view_) {
1455 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); 1466 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass());
1456 view_->DidReceiveRendererFrame(); 1467 view_->DidReceiveRendererFrame();
1457 } else { 1468 } else {
1458 cc::CompositorFrameAck ack; 1469 cc::CompositorFrameAck ack;
1459 if (frame->gl_frame_data) { 1470 if (frame->gl_frame_data) {
1460 ack.gl_frame_data = frame->gl_frame_data.Pass(); 1471 ack.gl_frame_data = frame->gl_frame_data.Pass();
1461 ack.gl_frame_data->sync_point = 0; 1472 ack.gl_frame_data->sync_point = 0;
1462 } else if (frame->delegated_frame_data) { 1473 } else if (frame->delegated_frame_data) {
1463 cc::TransferableResource::ReturnResources( 1474 cc::TransferableResource::ReturnResources(
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 swap_component.event_time - original_component.event_time; 2146 swap_component.event_time - original_component.event_time;
2136 for (size_t i = 0; i < original_component.event_count; i++) { 2147 for (size_t i = 0; i < original_component.event_count; i++) {
2137 UMA_HISTOGRAM_CUSTOM_COUNTS( 2148 UMA_HISTOGRAM_CUSTOM_COUNTS(
2138 "Event.Latency.TouchToScrollUpdateSwap", 2149 "Event.Latency.TouchToScrollUpdateSwap",
2139 delta.InMicroseconds(), 2150 delta.InMicroseconds(),
2140 1, 2151 1,
2141 1000000, 2152 1000000,
2142 100); 2153 100);
2143 } 2154 }
2144 } 2155 }
2156
2157 ui::LatencyInfo::LatencyComponent gpu_swap_component;
2158 if (!latency_info.FindLatency(
2159 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, &gpu_swap_component)) {
2160 return;
2161 }
2162
2163 ui::LatencyInfo::LatencyComponent composite_component;
2164 if (latency_info.FindLatency(ui::INPUT_EVENT_RENDERER_SWAP_RECEIVED_COMPONENT,
2165 GetLatencyComponentId(),
2166 &composite_component)) {
2167 base::TimeDelta delta =
2168 gpu_swap_component.event_time - composite_component.event_time;
2169 browser_composite_latency_history_.InsertSample(delta);
2170 }
2145 } 2171 }
2146 2172
2147 void RenderWidgetHostImpl::DidReceiveRendererFrame() { 2173 void RenderWidgetHostImpl::DidReceiveRendererFrame() {
2148 view_->DidReceiveRendererFrame(); 2174 view_->DidReceiveRendererFrame();
2149 } 2175 }
2150 2176
2151 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback( 2177 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback(
2152 int routing_id, 2178 int routing_id,
2153 int snapshot_id, 2179 int snapshot_id,
2154 gfx::Size snapshot_size, 2180 gfx::Size snapshot_size,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 const std::vector<ui::LatencyInfo>& latency_info) { 2279 const std::vector<ui::LatencyInfo>& latency_info) {
2254 for (size_t i = 0; i < latency_info.size(); i++) { 2280 for (size_t i = 0; i < latency_info.size(); i++) {
2255 std::set<RenderWidgetHostImpl*> rwhi_set; 2281 std::set<RenderWidgetHostImpl*> rwhi_set;
2256 for (ui::LatencyInfo::LatencyMap::const_iterator b = 2282 for (ui::LatencyInfo::LatencyMap::const_iterator b =
2257 latency_info[i].latency_components.begin(); 2283 latency_info[i].latency_components.begin();
2258 b != latency_info[i].latency_components.end(); 2284 b != latency_info[i].latency_components.end();
2259 ++b) { 2285 ++b) {
2260 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || 2286 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
2261 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || 2287 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
2262 b->first.first == ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT || 2288 b->first.first == ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT ||
2263 b->first.first == ui::TAB_SHOW_COMPONENT) { 2289 b->first.first == ui::TAB_SHOW_COMPONENT ||
2290 b->first.first == ui::INPUT_EVENT_RENDERER_SWAP_RECEIVED_COMPONENT) {
2264 // Matches with GetLatencyComponentId 2291 // Matches with GetLatencyComponentId
2265 int routing_id = b->first.second & 0xffffffff; 2292 int routing_id = b->first.second & 0xffffffff;
2266 int process_id = (b->first.second >> 32) & 0xffffffff; 2293 int process_id = (b->first.second >> 32) & 0xffffffff;
2267 RenderWidgetHost* rwh = 2294 RenderWidgetHost* rwh =
2268 RenderWidgetHost::FromID(process_id, routing_id); 2295 RenderWidgetHost::FromID(process_id, routing_id);
2269 if (!rwh) { 2296 if (!rwh) {
2270 continue; 2297 continue;
2271 } 2298 }
2272 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); 2299 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
2273 if (rwhi_set.insert(rwhi).second) 2300 if (rwhi_set.insert(rwhi).second)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() { 2335 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() {
2309 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2336 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2310 } 2337 }
2311 2338
2312 BrowserAccessibilityManager* 2339 BrowserAccessibilityManager*
2313 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2340 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2314 return delegate_ ? 2341 return delegate_ ?
2315 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2342 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2316 } 2343 }
2317 2344
2345 base::TimeDelta RenderWidgetHostImpl::GetEstimatedBrowserCompositeTime() {
2346 if (browser_composite_latency_history_.SampleCount() > 0) {
2347 return browser_composite_latency_history_.Percentile(
brianderson 2014/09/22 22:59:35 Let's add some slack to the estimate by multiplyin
orglofch 2014/09/22 23:55:14 Done.
2348 kBrowserCompositeLatencyEstimationPercentile);
2349 } else {
2350 return base::TimeDelta::FromMicroseconds(
2351 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60));
2352 }
2353 }
2354
2318 #if defined(OS_WIN) 2355 #if defined(OS_WIN)
2319 gfx::NativeViewAccessible 2356 gfx::NativeViewAccessible
2320 RenderWidgetHostImpl::GetParentNativeViewAccessible() { 2357 RenderWidgetHostImpl::GetParentNativeViewAccessible() {
2321 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; 2358 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL;
2322 } 2359 }
2323 #endif 2360 #endif
2324 2361
2325 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { 2362 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() {
2326 if (view_) 2363 if (view_)
2327 return view_->PreferredReadbackFormat(); 2364 return view_->PreferredReadbackFormat();
2328 return kN32_SkColorType; 2365 return kN32_SkColorType;
2329 } 2366 }
2330 2367
2331 } // namespace content 2368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698