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

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

Issue 2707243005: Discard compositor frames from unloaded web content (Closed)
Patch Set: Improved comments Created 3 years, 9 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 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 owned_by_render_frame_host_(false), 287 owned_by_render_frame_host_(false),
288 is_focused_(false), 288 is_focused_(false),
289 hung_renderer_delay_( 289 hung_renderer_delay_(
290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
291 hang_monitor_reason_( 291 hang_monitor_reason_(
292 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN), 292 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN),
293 hang_monitor_event_type_(blink::WebInputEvent::Undefined), 293 hang_monitor_event_type_(blink::WebInputEvent::Undefined),
294 last_event_type_(blink::WebInputEvent::Undefined), 294 last_event_type_(blink::WebInputEvent::Undefined),
295 new_content_rendering_delay_( 295 new_content_rendering_delay_(
296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), 296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
297 current_content_source_id_(0),
297 weak_factory_(this) { 298 weak_factory_(this) {
298 CHECK(delegate_); 299 CHECK(delegate_);
299 CHECK_NE(MSG_ROUTING_NONE, routing_id_); 300 CHECK_NE(MSG_ROUTING_NONE, routing_id_);
300 latency_tracker_.SetDelegate(delegate_); 301 latency_tracker_.SetDelegate(delegate_);
301 302
302 #if defined(OS_WIN) 303 #if defined(OS_WIN)
303 // Update the display color profile cache so that it is likely to be up to 304 // Update the display color profile cache so that it is likely to be up to
304 // date when the renderer process requests the color profile. 305 // date when the renderer process requests the color profile.
305 if (gfx::ICCProfile::CachedProfilesNeedUpdate()) { 306 if (gfx::ICCProfile::CachedProfilesNeedUpdate()) {
306 base::PostTaskWithTraits( 307 base::PostTaskWithTraits(
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1004
1004 void RenderWidgetHostImpl::StopHangMonitorTimeout() { 1005 void RenderWidgetHostImpl::StopHangMonitorTimeout() {
1005 if (hang_monitor_timeout_) { 1006 if (hang_monitor_timeout_) {
1006 hang_monitor_timeout_->Stop(); 1007 hang_monitor_timeout_->Stop();
1007 hang_monitor_reason_ = 1008 hang_monitor_reason_ =
1008 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN; 1009 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN;
1009 } 1010 }
1010 RendererIsResponsive(); 1011 RendererIsResponsive();
1011 } 1012 }
1012 1013
1013 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { 1014 void RenderWidgetHostImpl::StartNewContentRenderingTimeout(
1015 uint32_t next_source_id) {
1016 // current_content_source_id_ should be non-decreasing, but it is hard to
enne (OOO) 2017/02/28 19:02:23 Ignoring unsigned overflow here, how can raciness
kenrb 2017/02/28 22:18:44 Done. You're right, I think I was being overly con
1017 // guarantee that against raciness from a fast series of navigations.
1018 if (current_content_source_id_ < next_source_id || next_source_id == 0)
1019 current_content_source_id_ = next_source_id;
1014 // It is possible for a compositor frame to arrive before the browser is 1020 // It is possible for a compositor frame to arrive before the browser is
1015 // notified about the page being committed, in which case no timer is 1021 // notified about the page being committed, in which case no timer is
1016 // necessary. 1022 // necessary.
1017 if (received_paint_after_load_) { 1023 if (received_paint_after_load_) {
1018 received_paint_after_load_ = false; 1024 received_paint_after_load_ = false;
1019 return; 1025 return;
1020 } 1026 }
1021 1027
1022 new_content_rendering_timeout_->Start(new_content_rendering_delay_); 1028 new_content_rendering_timeout_->Start(new_content_rendering_delay_);
1023 } 1029 }
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame"); 1841 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame");
1836 1842
1837 ViewHostMsg_SwapCompositorFrame::Param param; 1843 ViewHostMsg_SwapCompositorFrame::Param param;
1838 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param)) 1844 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
1839 return false; 1845 return false;
1840 cc::CompositorFrame frame(std::move(std::get<1>(param))); 1846 cc::CompositorFrame frame(std::move(std::get<1>(param)));
1841 uint32_t compositor_frame_sink_id = std::get<0>(param); 1847 uint32_t compositor_frame_sink_id = std::get<0>(param);
1842 std::vector<IPC::Message> messages_to_deliver_with_frame; 1848 std::vector<IPC::Message> messages_to_deliver_with_frame;
1843 messages_to_deliver_with_frame.swap(std::get<2>(param)); 1849 messages_to_deliver_with_frame.swap(std::get<2>(param));
1844 1850
1851 // Ignore this frame if its content has already been unloaded.
enne (OOO) 2017/02/28 19:02:23 I wonder if this early out needs to go after some
kenrb 2017/02/28 22:18:44 I've moved it after the latency tracking, but for
1852 if (frame.metadata.content_source_id < current_content_source_id_)
1853 return false;
1854
1845 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, 1855 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info,
1846 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { 1856 "RenderWidgetHostImpl::OnSwapCompositorFrame")) {
1847 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); 1857 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info);
1848 } 1858 }
1849 1859
1850 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info); 1860 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info);
1851 1861
1852 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata); 1862 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata);
1853 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized); 1863 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized);
1854 if (touch_emulator_) 1864 if (touch_emulator_)
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 // different from the receiver's. 2540 // different from the receiver's.
2531 file_system_file.url = 2541 file_system_file.url =
2532 GURL(storage::GetIsolatedFileSystemRootURIString( 2542 GURL(storage::GetIsolatedFileSystemRootURIString(
2533 file_system_url.origin(), filesystem_id, std::string()) 2543 file_system_url.origin(), filesystem_id, std::string())
2534 .append(register_name)); 2544 .append(register_name));
2535 file_system_file.filesystem_id = filesystem_id; 2545 file_system_file.filesystem_id = filesystem_id;
2536 } 2546 }
2537 } 2547 }
2538 2548
2539 } // namespace content 2549 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698