Index: cc/trees/single_thread_proxy.cc |
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc |
index 07b5afa607a72b95240466e413a98e6d880c3ae8..89cc5942b1bed455b9c7a57ea9513a86ea86245b 100644 |
--- a/cc/trees/single_thread_proxy.cc |
+++ b/cc/trees/single_thread_proxy.cc |
@@ -52,6 +52,7 @@ SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, |
inside_synchronous_composite_(false), |
compositor_frame_sink_creation_requested_(false), |
compositor_frame_sink_lost_(true), |
+ frame_sink_bound_weak_factory_(this), |
weak_factory_(this) { |
TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
DCHECK(task_runner_provider_); |
@@ -123,6 +124,7 @@ void SingleThreadProxy::RequestNewCompositorFrameSink() { |
void SingleThreadProxy::ReleaseCompositorFrameSink() { |
compositor_frame_sink_lost_ = true; |
+ frame_sink_bound_weak_factory_.InvalidateWeakPtrs(); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
return layer_tree_host_impl_->ReleaseCompositorFrameSink(); |
@@ -141,6 +143,7 @@ void SingleThreadProxy::SetCompositorFrameSink( |
} |
if (success) { |
+ frame_sink_bound_weak_ptr_ = frame_sink_bound_weak_factory_.GetWeakPtr(); |
layer_tree_host_->DidInitializeCompositorFrameSink(); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->DidCreateAndInitializeCompositorFrameSink(); |
@@ -403,6 +406,7 @@ void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { |
TRACE_EVENT0("cc", |
"SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); |
+ frame_sink_bound_weak_factory_.InvalidateWeakPtrs(); |
danakj
2017/04/18 20:58:42
same here
Saman Sami
2017/04/18 21:37:13
Removed.
|
{ |
DebugScopedSetMainThread main(task_runner_provider_); |
// This must happen before we notify the scheduler as it may try to recreate |
@@ -425,7 +429,12 @@ void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() { |
"SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread"); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); |
- layer_tree_host_->DidReceiveCompositorFrameAck(); |
+ // We do a PostTask here because freeing resources in some cases (such as in |
+ // TextureLayer) is PostTasked and we want to make sure ack is received after |
+ // resources are returned. |
+ task_runner_provider_->MainThreadTaskRunner()->PostTask( |
+ FROM_HERE, base::Bind(&SingleThreadProxy::DidReceiveCompositorFrameAck, |
+ frame_sink_bound_weak_ptr_)); |
} |
void SingleThreadProxy::OnDrawForCompositorFrameSink( |
@@ -794,4 +803,8 @@ void SingleThreadProxy::DidFinishImplFrame() { |
#endif |
} |
+void SingleThreadProxy::DidReceiveCompositorFrameAck() { |
+ layer_tree_host_->DidReceiveCompositorFrameAck(); |
+} |
+ |
} // namespace cc |