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

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

Issue 2767933002: [cc] Don't send missed BeginFrames with past deadline.
Patch Set: add ExternalBFS tests, don't check in DelayBasedBFS. Created 3 years, 8 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 view_.GetWindowAndroid()->RemoveObserver(this); 1549 view_.GetWindowAndroid()->RemoveObserver(this);
1550 if (!using_browser_compositor_) 1550 if (!using_browser_compositor_)
1551 SetBeginFrameSource(nullptr); 1551 SetBeginFrameSource(nullptr);
1552 // If the DFH has already been destroyed, it will have cleaned itself up. 1552 // If the DFH has already been destroyed, it will have cleaned itself up.
1553 // This happens in some WebView cases. 1553 // This happens in some WebView cases.
1554 if (delegated_frame_host_) 1554 if (delegated_frame_host_)
1555 delegated_frame_host_->DetachFromCompositor(); 1555 delegated_frame_host_->DetachFromCompositor();
1556 DCHECK(!begin_frame_source_); 1556 DCHECK(!begin_frame_source_);
1557 } 1557 }
1558 1558
1559 void RenderWidgetHostViewAndroid::SendBeginFrame(cc::BeginFrameArgs args) { 1559 void RenderWidgetHostViewAndroid::SendBeginFrame(
1560 const cc::BeginFrameArgs& args) {
1560 TRACE_EVENT2("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", 1561 TRACE_EVENT2("cc", "RenderWidgetHostViewAndroid::SendBeginFrame",
1561 "frame_number", args.sequence_number, "frame_time_us", 1562 "frame_number", args.sequence_number, "frame_time_us",
1562 args.frame_time.ToInternalValue()); 1563 args.frame_time.ToInternalValue());
1563 1564
1564 // Synchronous compositor does not use deadline-based scheduling.
1565 // TODO(brianderson): Replace this hardcoded deadline after Android
1566 // switches to Surfaces and the Browser's commit isn't in the critical path.
1567 args.deadline = sync_compositor_ ? base::TimeTicks()
1568 : args.frame_time + (args.interval * 0.6);
1569 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); 1565 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args));
1570 if (sync_compositor_) 1566 if (sync_compositor_)
1571 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); 1567 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid());
1572 } 1568 }
1573 1569
1574 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { 1570 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
1575 bool needs_animate = false; 1571 bool needs_animate = false;
1576 if (overscroll_controller_ && !is_in_vr_) { 1572 if (overscroll_controller_ && !is_in_vr_) {
1577 needs_animate |= overscroll_controller_->Animate( 1573 needs_animate |= overscroll_controller_->Animate(
1578 frame_time, content_view_core_->GetViewAndroid()->GetLayer()); 1574 frame_time, content_view_core_->GetViewAndroid()->GetLayer());
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 1982
1987 void RenderWidgetHostViewAndroid::OnDetachCompositor() { 1983 void RenderWidgetHostViewAndroid::OnDetachCompositor() {
1988 DCHECK(content_view_core_); 1984 DCHECK(content_view_core_);
1989 DCHECK(using_browser_compositor_); 1985 DCHECK(using_browser_compositor_);
1990 RunAckCallbacks(); 1986 RunAckCallbacks();
1991 overscroll_controller_.reset(); 1987 overscroll_controller_.reset();
1992 delegated_frame_host_->DetachFromCompositor(); 1988 delegated_frame_host_->DetachFromCompositor();
1993 } 1989 }
1994 1990
1995 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) { 1991 void RenderWidgetHostViewAndroid::OnBeginFrame(const cc::BeginFrameArgs& args) {
1992 // TODO(eseckler): Acknowledge BeginFrames.
1996 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame"); 1993 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnBeginFrame");
1997 if (!host_) 1994 if (!host_)
1998 return; 1995 return;
1999 1996
2000 // In sync mode, we disregard missed frame args to ensure that 1997 // In sync mode, we disregard missed frame args to ensure that
2001 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called 1998 // SynchronousCompositorBrowserFilter::SyncStateAfterVSync will be called
2002 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration. 1999 // during WindowAndroid::WindowBeginFrameSource::OnVSync() observer iteration.
2003 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED) 2000 if (sync_compositor_ && args.type == cc::BeginFrameArgs::MISSED)
2004 return; 2001 return;
2005 2002
2003 cc::BeginFrameArgs adjusted_args = args;
2004
2005 if (sync_compositor_) {
2006 // Synchronous compositor does not use deadline-based scheduling.
2007 adjusted_args.deadline = base::TimeTicks();
2008 } else {
2009 // TODO(brianderson): Replace this hardcoded deadline after Android
2010 // switches to Surfaces and the Browser's commit isn't in the critical path.
2011 adjusted_args.deadline =
2012 adjusted_args.frame_time + (adjusted_args.interval * 0.6);
2013 // Avoid unnecessary IPC round trips of missed args with past deadline.
2014 if (adjusted_args.type == cc::BeginFrameArgs::MISSED &&
2015 base::TimeTicks::Now() > adjusted_args.deadline) {
2016 return;
2017 }
2018 }
2019
2006 // Update |last_begin_frame_args_| before handling 2020 // Update |last_begin_frame_args_| before handling
2007 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from 2021 // |outstanding_begin_frame_requests_| to prevent the BeginFrameSource from
2008 // sending the same MISSED args in infinite recursion. This may otherwise 2022 // sending the same MISSED args in infinite recursion. This may otherwise
2009 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput() 2023 // happen if |host_->FlushInput()| causes a synchronous OnSetNeedsFlushInput()
2010 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). 2024 // which can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame().
2011 // By setting |last_begin_frame_args_|, we indicate to the source not to send 2025 // By setting |last_begin_frame_args_|, we indicate to the source not to send
2012 // the same args during |AddObserver()| again. 2026 // the same args during |AddObserver()| again.
2013 last_begin_frame_args_ = args; 2027 last_begin_frame_args_ = args;
2014 2028
2015 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) { 2029 if (outstanding_begin_frame_requests_ & FLUSH_INPUT) {
2016 ClearBeginFrameRequest(FLUSH_INPUT); 2030 ClearBeginFrameRequest(FLUSH_INPUT);
2017 host_->FlushInput(); 2031 host_->FlushInput();
2018 } 2032 }
2019 2033
2020 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) || 2034 if ((outstanding_begin_frame_requests_ & BEGIN_FRAME) ||
2021 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) { 2035 (outstanding_begin_frame_requests_ & PERSISTENT_BEGIN_FRAME)) {
2022 ClearBeginFrameRequest(BEGIN_FRAME); 2036 ClearBeginFrameRequest(BEGIN_FRAME);
2023 SendBeginFrame(args); 2037 SendBeginFrame(adjusted_args);
2024 } 2038 }
2025 } 2039 }
2026 2040
2027 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs() 2041 const cc::BeginFrameArgs& RenderWidgetHostViewAndroid::LastUsedBeginFrameArgs()
2028 const { 2042 const {
2029 return last_begin_frame_args_; 2043 return last_begin_frame_args_;
2030 } 2044 }
2031 2045
2032 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) { 2046 void RenderWidgetHostViewAndroid::OnBeginFrameSourcePausedChanged(bool paused) {
2033 // The BeginFrameSources we listen to don't use this. For WebView, we signal 2047 // The BeginFrameSources we listen to don't use this. For WebView, we signal
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 2154
2141 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); 2155 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor();
2142 if (!compositor) 2156 if (!compositor)
2143 return; 2157 return;
2144 2158
2145 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( 2159 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>(
2146 overscroll_refresh_handler, compositor, view_.GetDipScale()); 2160 overscroll_refresh_handler, compositor, view_.GetDipScale());
2147 } 2161 }
2148 2162
2149 } // namespace content 2163 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698