Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index 93efaa57403be643d9883fe54cf409cb77e6ae52..82124033ed4dee1007fdc9d174ca29d80c863f93 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -377,6 +377,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), |
| @@ -1165,6 +1166,11 @@ void RenderWidget::AutoResizeCompositor() { |
| } |
| void RenderWidget::initializeLayerTreeView() { |
| + // The host is currently shutting down and any old compositors have |
| + // been destroyed, so don't create any new ones. |
| + if (host_closing_) |
|
danakj
2014/07/02 21:31:42
Do you think this can/should be a DCHECK one day?
enne (OOO)
2014/07/10 20:37:42
Done.
|
| + return; |
| + |
| compositor_ = RenderWidgetCompositor::Create( |
| this, is_threaded_compositing_enabled_); |
| compositor_->setViewportSize(size_, physical_backing_size_); |
| @@ -1172,6 +1178,13 @@ void RenderWidget::initializeLayerTreeView() { |
| StartCompositor(); |
| } |
| +void RenderWidget::DestroyLayerTreeView() { |
| + if (!compositor_) |
| + return; |
| + webwidget_->willCloseLayerTreeView(); |
| + compositor_.reset(); |
| +} |
| + |
| blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| return compositor_.get(); |
| } |
| @@ -1184,8 +1197,6 @@ void RenderWidget::suppressCompositorScheduling(bool enable) { |
| 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. |
| @@ -1289,6 +1300,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(); |
|
enne (OOO)
2014/07/02 21:19:43
This is the Chromium side of preventing the race t
|
| + // Also prevent new compositors from being created. |
| + host_closing_ = true; |
| Send(new ViewHostMsg_Close(routing_id_)); |
| } |
| @@ -1328,8 +1345,7 @@ void RenderWidget::QueueSyntheticGesture( |
| void RenderWidget::Close() { |
| if (webwidget_) { |
| - webwidget_->willCloseLayerTreeView(); |
| - compositor_.reset(); |
| + DestroyLayerTreeView(); |
| webwidget_->close(); |
| webwidget_ = NULL; |
| } |