Commit 694d4b9a authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Avoid crash in ThumbnailTabHelper::StartVideoCapture()

See comment in source code linked to this bug for an explanation.
Attached bug contains crash report link.

Bug: 1048363
Change-Id: I9b6e3cd10bd8fe1ea5466e950a3a47b61659b191
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037648
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738432}
parent fe5f4b47
...@@ -103,8 +103,7 @@ void ThumbnailTabHelper::ThumbnailImageBeingObservedChanged( ...@@ -103,8 +103,7 @@ void ThumbnailTabHelper::ThumbnailImageBeingObservedChanged(
is_being_observed_ = is_being_observed; is_being_observed_ = is_being_observed;
if (is_being_observed && !captured_loaded_thumbnail_since_tab_hidden_) { if (is_being_observed && !captured_loaded_thumbnail_since_tab_hidden_) {
scoped_capture_ = std::make_unique<ScopedCapture>(this); scoped_capture_ = std::make_unique<ScopedCapture>(this);
if (GetView()) StartVideoCapture();
StartVideoCapture();
} else if (!is_being_observed) { } else if (!is_being_observed) {
scoped_capture_.reset(); scoped_capture_.reset();
} }
...@@ -186,13 +185,11 @@ void ThumbnailTabHelper::StartVideoCapture() { ...@@ -186,13 +185,11 @@ void ThumbnailTabHelper::StartVideoCapture() {
if (video_capturer_) if (video_capturer_)
return; return;
// This can be triggered by someone starting to observe a web contents by // This pointer can become null before this method is called - see
// incrementing its capture count, or it can happen opportunistically when a // RenderWidgetHost::GetView() for details.
// renderer is available, because we want to capture thumbnails while we can
// before a page is frozen or swapped out.
content::RenderWidgetHostView* const source_view = GetView(); content::RenderWidgetHostView* const source_view = GetView();
DCHECK(source_view); if (!source_view)
return;
// Get the source size and scale. // Get the source size and scale.
const float scale_factor = source_view->GetDeviceScaleFactor(); const float scale_factor = source_view->GetDeviceScaleFactor();
......
...@@ -64,6 +64,11 @@ class ThumbnailTabHelper ...@@ -64,6 +64,11 @@ class ThumbnailTabHelper
bool ShouldKeepUpdatingThumbnail() const; bool ShouldKeepUpdatingThumbnail() const;
// Begins periodic capture of thumbnails from a loading page.
// This can be triggered by someone starting to observe a web contents by
// incrementing its capture count, or it can happen opportunistically when a
// renderer is available, because we want to capture thumbnails while we can
// before a page is frozen or swapped out.
void StartVideoCapture(); void StartVideoCapture();
void StopVideoCapture(); void StopVideoCapture();
void CaptureThumbnailOnTabSwitch(); void CaptureThumbnailOnTabSwitch();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment