Index: content/renderer/render_widget.cc |
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
index ef30ede736cadf20c4d54550b351d73f85c0aa7d..b11b11c135b22b15292396edcfe72bc767ee33f3 100644 |
--- a/content/renderer/render_widget.cc |
+++ b/content/renderer/render_widget.cc |
@@ -393,6 +393,7 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type, |
handling_event_type_(WebInputEvent::Undefined), |
ignore_ack_for_mouse_move_from_debugger_(false), |
closing_(false), |
+ host_closing_(false), |
is_swapped_out_(swapped_out), |
input_method_is_active_(false), |
text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
@@ -1199,6 +1200,8 @@ void RenderWidget::AutoResizeCompositor() { |
} |
void RenderWidget::initializeLayerTreeView() { |
+ DCHECK(!host_closing_); |
+ |
compositor_ = |
RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
compositor_->setViewportSize(size_, physical_backing_size_); |
@@ -1206,20 +1209,21 @@ void RenderWidget::initializeLayerTreeView() { |
StartCompositor(); |
} |
-blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
- return compositor_.get(); |
+void RenderWidget::DestroyLayerTreeView() { |
+ // Always send this notification to prevent new layer tree views from |
+ // being created, even if one hasn't been created yet. |
+ if (webwidget_) |
+ webwidget_->willCloseLayerTreeView(); |
+ compositor_.reset(); |
} |
-void RenderWidget::suppressCompositorScheduling(bool enable) { |
- if (compositor_) |
- compositor_->SetSuppressScheduleComposite(enable); |
+blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
+ return compositor_.get(); |
} |
void RenderWidget::willBeginCompositorFrame() { |
TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
- DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); |
- |
// The following two can result in further layout and possibly |
// enable GPU acceleration so they need to be called before any painting |
// is done. |
@@ -1376,6 +1380,12 @@ void RenderWidget::didBlur() { |
} |
void RenderWidget::DoDeferredClose() { |
+ // No more compositing is possible. This prevents shutdown races between |
+ // previously posted CreateOutputSurface tasks and the host being unable to |
+ // create them because the close message was handled. |
+ DestroyLayerTreeView(); |
+ // Also prevent new compositors from being created. |
+ host_closing_ = true; |
Send(new ViewHostMsg_Close(routing_id_)); |
} |
@@ -1415,9 +1425,8 @@ void RenderWidget::QueueSyntheticGesture( |
void RenderWidget::Close() { |
screen_metrics_emulator_.reset(); |
+ DestroyLayerTreeView(); |
if (webwidget_) { |
- webwidget_->willCloseLayerTreeView(); |
- compositor_.reset(); |
webwidget_->close(); |
webwidget_ = NULL; |
} |