diff options
author | boliu <boliu@chromium.org> | 2014-10-06 21:35:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 04:35:55 +0000 |
commit | 4aa98dc6f54564fa3a06128ff299ff7eefa9a946 (patch) | |
tree | f60b209a109740936441d294386a31ffcc6a93bc /android_webview/browser | |
parent | 45762d28d013c5c985da49eef8d09ca30330012f (diff) | |
download | chromium_src-4aa98dc6f54564fa3a06128ff299ff7eefa9a946.zip chromium_src-4aa98dc6f54564fa3a06128ff299ff7eefa9a946.tar.gz chromium_src-4aa98dc6f54564fa3a06128ff299ff7eefa9a946.tar.bz2 |
aw: Do not cancel fallback tick on pipeline stall
This can cause a live lock if pipeline is stalled waiting for the
fallback tick. However we cannot skip invalidate to avoid drawing a bad
frame.
BUG=420702
Review URL: https://codereview.chromium.org/630953003
Cr-Commit-Position: refs/heads/master@{#298369}
Diffstat (limited to 'android_webview/browser')
-rw-r--r-- | android_webview/browser/browser_view_renderer.cc | 34 | ||||
-rw-r--r-- | android_webview/browser/browser_view_renderer.h | 9 |
2 files changed, 31 insertions, 12 deletions
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc index 505919d..50fe66c 100644 --- a/android_webview/browser/browser_view_renderer.cc +++ b/android_webview/browser/browser_view_renderer.cc @@ -119,6 +119,7 @@ BrowserViewRenderer::BrowserViewRenderer( clear_view_(false), compositor_needs_continuous_invalidate_(false), block_invalidates_(false), + fallback_tick_pending_(false), width_(0), height_(0) { CHECK(web_contents_); @@ -265,8 +266,7 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_PreviousFrameUnconsumed", TRACE_EVENT_SCOPE_THREAD); - // TODO(boliu): Rename this method. We didn't actually composite here. - DidComposite(); + SkippedCompositeInDraw(); return client_->RequestDrawGL(java_canvas, false); } @@ -316,7 +316,7 @@ void BrowserViewRenderer::UpdateParentDrawConstraints() { !parent_draw_constraints_.Equals( shared_renderer_state_->ParentDrawConstraints())) { shared_renderer_state_->SetForceInvalidateOnNextDrawGL(false); - EnsureContinuousInvalidation(true); + EnsureContinuousInvalidation(true, false); } } @@ -398,7 +398,7 @@ void BrowserViewRenderer::ClearView() { clear_view_ = true; // Always invalidate ignoring the compositor to actually clear the webview. - EnsureContinuousInvalidation(true); + EnsureContinuousInvalidation(true, false); } void BrowserViewRenderer::SetIsPaused(bool paused) { @@ -408,7 +408,7 @@ void BrowserViewRenderer::SetIsPaused(bool paused) { "paused", paused); is_paused_ = paused; - EnsureContinuousInvalidation(false); + EnsureContinuousInvalidation(false, false); } void BrowserViewRenderer::SetViewVisibility(bool view_visible) { @@ -427,7 +427,7 @@ void BrowserViewRenderer::SetWindowVisibility(bool window_visible) { "window_visible", window_visible); window_visible_ = window_visible; - EnsureContinuousInvalidation(false); + EnsureContinuousInvalidation(false, false); } void BrowserViewRenderer::OnSizeChanged(int width, int height) { @@ -512,7 +512,7 @@ void BrowserViewRenderer::SetContinuousInvalidate(bool invalidate) { invalidate); compositor_needs_continuous_invalidate_ = invalidate; - EnsureContinuousInvalidation(false); + EnsureContinuousInvalidation(false, false); } void BrowserViewRenderer::SetDipScale(float dip_scale) { @@ -678,7 +678,9 @@ void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll, client_->DidOverscroll(rounded_overscroll_delta); } -void BrowserViewRenderer::EnsureContinuousInvalidation(bool force_invalidate) { +void BrowserViewRenderer::EnsureContinuousInvalidation( + bool force_invalidate, + bool skip_reschedule_tick) { // This method should be called again when any of these conditions change. bool need_invalidate = compositor_needs_continuous_invalidate_ || force_invalidate; @@ -701,18 +703,23 @@ void BrowserViewRenderer::EnsureContinuousInvalidation(bool force_invalidate) { return; block_invalidates_ = compositor_needs_continuous_invalidate_; + if (skip_reschedule_tick && fallback_tick_pending_) + return; // Unretained here is safe because the callbacks are cancelled when // they are destroyed. post_fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::PostFallbackTick, base::Unretained(this))); fallback_tick_fired_.Cancel(); + fallback_tick_pending_ = false; // No need to reschedule fallback tick if compositor does not need to be // ticked. This can happen if this is reached because force_invalidate is // true. - if (compositor_needs_continuous_invalidate_) + if (compositor_needs_continuous_invalidate_) { + fallback_tick_pending_ = true; ui_task_runner_->PostTask(FROM_HERE, post_fallback_tick_.callback()); + } } void BrowserViewRenderer::PostFallbackTick() { @@ -739,6 +746,7 @@ void BrowserViewRenderer::FallbackTickFired() { // This should only be called if OnDraw or DrawGL did not come in time, which // means block_invalidates_ must still be true. DCHECK(block_invalidates_); + fallback_tick_pending_ = false; if (compositor_needs_continuous_invalidate_ && compositor_) { ForceFakeCompositeSW(); } else { @@ -768,7 +776,13 @@ void BrowserViewRenderer::DidComposite() { block_invalidates_ = false; post_fallback_tick_.Cancel(); fallback_tick_fired_.Cancel(); - EnsureContinuousInvalidation(false); + fallback_tick_pending_ = false; + EnsureContinuousInvalidation(false, false); +} + +void BrowserViewRenderer::SkippedCompositeInDraw() { + block_invalidates_ = false; + EnsureContinuousInvalidation(false, true); } std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h index 717225e..31d952e 100644 --- a/android_webview/browser/browser_view_renderer.h +++ b/android_webview/browser/browser_view_renderer.h @@ -149,11 +149,15 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient, void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); // Checks the continuous invalidate and block invalidate state, and schedule // invalidates appropriately. If |force_invalidate| is true, then send a view - // invalidate regardless of compositor expectation. - void EnsureContinuousInvalidation(bool force_invalidate); + // invalidate regardless of compositor expectation. If |skip_reschedule_tick| + // is true and if there is already a pending fallback tick, don't reschedule + // them. + void EnsureContinuousInvalidation(bool force_invalidate, + bool skip_reschedule_tick); bool OnDrawSoftware(jobject java_canvas); bool CompositeSW(SkCanvas* canvas); void DidComposite(); + void SkippedCompositeInDraw(); scoped_ptr<base::Value> RootLayerStateAsValue( const gfx::Vector2dF& total_scroll_offset_dip, const gfx::SizeF& scrollable_size_dip); @@ -219,6 +223,7 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient, base::CancelableClosure post_fallback_tick_; base::CancelableClosure fallback_tick_fired_; + bool fallback_tick_pending_; int width_; int height_; |