Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Android] Speculative fix for crash during overscroll effect creation
Browse files Browse the repository at this point in the history
Crash reports indicate that the WindowAndroid's Compositor may be NULL
during |RenderWidgetHostViewAndroid::SetContentViewCore()|. While this
is a somewhat surprising result, it is in theory possible and should
probably not be fatal. Avoid creating the overscroll effect in this
case, instead creating it after the compositor is (re-)attached.

BUG=407208

Review URL: https://codereview.chromium.org/503813003

Cr-Commit-Position: refs/heads/master@{#291835}
  • Loading branch information
jdduke authored and Commit bot committed Aug 26, 2014
1 parent b5ca81a commit 7936233
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions content/browser/renderer_host/render_widget_host_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ void RenderWidgetHostViewAndroid::SetContentViewCore(

bool resize = false;
if (content_view_core != content_view_core_) {
overscroll_effect_.reset();
selection_controller_.reset();
ReleaseLocksOnSurface();
resize = true;
Expand Down Expand Up @@ -1631,9 +1632,8 @@ void RenderWidgetHostViewAndroid::SetContentViewCore(
if (!selection_controller_)
selection_controller_.reset(new TouchSelectionController(this));

if (!content_view_core_)
overscroll_effect_.reset();
else if (overscroll_effect_enabled_ && !overscroll_effect_)
if (overscroll_effect_enabled_ && !overscroll_effect_ &&
content_view_core_->GetWindowAndroid()->GetCompositor())
overscroll_effect_ = CreateOverscrollEffect(content_view_core_);
}

Expand All @@ -1656,10 +1656,18 @@ void RenderWidgetHostViewAndroid::OnCompositingDidCommit() {
RunAckCallbacks();
}


void RenderWidgetHostViewAndroid::OnAttachCompositor() {
DCHECK(content_view_core_);
if (overscroll_effect_enabled_ && !overscroll_effect_)
overscroll_effect_ = CreateOverscrollEffect(content_view_core_);
}

void RenderWidgetHostViewAndroid::OnDetachCompositor() {
DCHECK(content_view_core_);
DCHECK(!using_synchronous_compositor_);
RunAckCallbacks();
overscroll_effect_.reset();
}

void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid

// ui::WindowAndroidObserver implementation.
virtual void OnCompositingDidCommit() OVERRIDE;
virtual void OnAttachCompositor() OVERRIDE {}
virtual void OnAttachCompositor() OVERRIDE;
virtual void OnDetachCompositor() OVERRIDE;
virtual void OnVSync(base::TimeTicks frame_time,
base::TimeDelta vsync_period) OVERRIDE;
Expand Down

0 comments on commit 7936233

Please sign in to comment.