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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2707243005: Discard compositor frames from unloaded web content (Closed)
Patch Set: Add default value for source ID in frame metadata 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 side-by-side diff with in-line comments
Download patch
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 15b899540dc237e86f109eb9d4e65a42d230ea75..4afec65e2be43a227764516076b2ccd59f26758f 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -294,6 +294,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
last_event_type_(blink::WebInputEvent::Undefined),
new_content_rendering_delay_(
base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
+ current_content_source_id_(0),
weak_factory_(this) {
CHECK(delegate_);
CHECK_NE(MSG_ROUTING_NONE, routing_id_);
@@ -985,7 +986,9 @@ void RenderWidgetHostImpl::StopHangMonitorTimeout() {
RendererIsResponsive();
}
-void RenderWidgetHostImpl::StartNewContentRenderingTimeout() {
+void RenderWidgetHostImpl::StartNewContentRenderingTimeout(
+ uint32_t next_source_id) {
+ current_content_source_id_ = next_source_id;
// It is possible for a compositor frame to arrive before the browser is
// notified about the page being committed, in which case no timer is
// necessary.
@@ -1829,7 +1832,13 @@ bool RenderWidgetHostImpl::OnSwapCompositorFrame(
if (touch_emulator_)
touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
- if (view_) {
+ // Ignore this frame if its content has already been unloaded. Source ID
+ // is always zero for an OOPIF because we are only concerned with displaying
+ // stale graphics on top-level frames. We accept frames that have a source ID
+ // greater than |current_content_source_id_| because in some cases the first
+ // compositor frame can arrive before the navigation commit message that
+ // updates that value.
+ if (view_ && frame.metadata.content_source_id >= current_content_source_id_) {
view_->OnSwapCompositorFrame(compositor_frame_sink_id, std::move(frame));
view_->DidReceiveRendererFrame();
} else {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698