Skip to content

Commit

Permalink
Crash fix for AuraWindowCaptureMachine/ReadbackYUV
Browse files Browse the repository at this point in the history
Adds missing ContextFactoryObserver::OnLostResources() implementation
that is required for when GLHelper is destroyed/re-created because the
current ReadbackYUVPipeline instance is no longer valid.

TBR=wez@chromium.org

Bug: 760251
Change-Id: I85f54b60b32501aa3e08e1dcca7891ce739a913a
Reviewed-on: https://chromium-review.googlesource.com/647409
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499354}
  • Loading branch information
miu-chromium committed Sep 2, 2017
1 parent ce59cd0 commit 0c0a2d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 13 additions & 0 deletions content/browser/media/capture/aura_window_capture_machine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ bool AuraWindowCaptureMachine::InternalStart(
// Update capture size.
UpdateCaptureSize();

// Start observing for GL context losses.
ImageTransportFactory::GetInstance()->GetContextFactory()->AddObserver(this);

// Start observing compositor updates.
aura::WindowTreeHost* const host = desktop_window_->GetHost();
ui::Compositor* const compositor = host ? host->compositor() : nullptr;
Expand Down Expand Up @@ -165,6 +168,11 @@ void AuraWindowCaptureMachine::InternalStop(const base::Closure& callback) {
cursor_renderer_.reset();
}

// Stop observing for GL context losses.
ImageTransportFactory::GetInstance()->GetContextFactory()->RemoveObserver(
this);
OnLostResources();

callback.Run();
}

Expand Down Expand Up @@ -462,4 +470,9 @@ void AuraWindowCaptureMachine::OnCompositingShuttingDown(
compositor->RemoveAnimationObserver(this);
}

void AuraWindowCaptureMachine::OnLostResources() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
yuv_readback_pipeline_.reset();
}

} // namespace content
11 changes: 7 additions & 4 deletions content/browser/media/capture/aura_window_capture_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class ReadbackYUVInterface;

namespace content {

class AuraWindowCaptureMachine
: public media::VideoCaptureMachine,
public aura::WindowObserver,
public ui::CompositorAnimationObserver {
class AuraWindowCaptureMachine : public media::VideoCaptureMachine,
public aura::WindowObserver,
public ui::ContextFactoryObserver,
public ui::CompositorAnimationObserver {
public:
AuraWindowCaptureMachine();
~AuraWindowCaptureMachine() override;
Expand Down Expand Up @@ -92,6 +92,9 @@ class AuraWindowCaptureMachine
const CaptureFrameCallback& capture_frame_cb,
std::unique_ptr<viz::CopyOutputResult> result);

// ui::ContextFactoryObserver implementation.
void OnLostResources() override;

// Renders the cursor if needed and then delivers the captured frame.
static void CopyOutputFinishedForVideo(
base::WeakPtr<AuraWindowCaptureMachine> machine,
Expand Down

0 comments on commit 0c0a2d0

Please sign in to comment.