Commit 02d11389 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

cc: Make sure a CompletionEvent is always signaled.

It looks like there is a CompletionEvent that is never getting signaled
from the compositor thread, and the main-thread stays blocked on it.
This causes a fair number of hangs in the renderers (~30% of all hangs
or crashes in cc/ code in stable channel on Windows). Try using a
ScopedCompletionEvent to make sure all CompletionEvents are always
signaled, and see if that helps.

BUG=622080

Change-Id: Ic25089f0e4f671182b18c1b44e278196eeb040c2
Reviewed-on: https://chromium-review.googlesource.com/c/1332726Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607868}
parent 536b73eb
......@@ -40,13 +40,22 @@ unsigned int nextBeginFrameId = 0;
} // namespace
// Ensures that a CompletionEvent is always signaled.
class ScopedCompletionEvent {
public:
explicit ScopedCompletionEvent(CompletionEvent* event) : event_(event) {}
~ScopedCompletionEvent() { event_->Signal(); }
private:
CompletionEvent* const event_;
DISALLOW_COPY_AND_ASSIGN(ScopedCompletionEvent);
};
ProxyImpl::ProxyImpl(base::WeakPtr<ProxyMain> proxy_main_weak_ptr,
LayerTreeHost* layer_tree_host,
TaskRunnerProvider* task_runner_provider)
: layer_tree_host_id_(layer_tree_host->GetId()),
commit_completion_waits_for_activation_(false),
commit_completion_event_(nullptr),
activation_completion_event_(nullptr),
next_frame_is_newly_committed_frame_(false),
inside_draw_(false),
input_throttled_until_commit_(false),
......@@ -261,7 +270,8 @@ void ProxyImpl::NotifyReadyToCommitOnImpl(
host_impl_->ReadyToCommit();
commit_completion_event_ = completion;
commit_completion_event_ =
std::make_unique<ScopedCompletionEvent>(completion);
commit_completion_waits_for_activation_ = hold_commit_for_activation;
DCHECK(!blocked_main_commit().layer_tree_host);
......@@ -440,7 +450,6 @@ void ProxyImpl::DidActivateSyncTree() {
if (activation_completion_event_) {
TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
TRACE_EVENT_SCOPE_THREAD);
activation_completion_event_->Signal();
activation_completion_event_ = nullptr;
}
}
......@@ -578,9 +587,7 @@ void ProxyImpl::ScheduledActionCommit() {
// already activated if there was no work to be done.
TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
commit_completion_waits_for_activation_ = false;
activation_completion_event_ = commit_completion_event_;
} else {
commit_completion_event_->Signal();
activation_completion_event_ = std::move(commit_completion_event_);
}
commit_completion_event_ = nullptr;
......
......@@ -20,6 +20,8 @@ class LayerTreeHost;
class ProxyMain;
class RenderFrameMetadataObserver;
class ScopedCompletionEvent;
// This class aggregates all the interactions that the main side of the
// compositor needs to have with the impl side.
// The class is created and lives on the impl thread.
......@@ -143,10 +145,10 @@ class CC_EXPORT ProxyImpl : public LayerTreeHostImplClient,
bool commit_completion_waits_for_activation_;
// Set when the main thread is waiting on a commit to complete.
CompletionEvent* commit_completion_event_;
std::unique_ptr<ScopedCompletionEvent> commit_completion_event_;
// Set when the main thread is waiting for activation to complete.
CompletionEvent* activation_completion_event_;
std::unique_ptr<ScopedCompletionEvent> activation_completion_event_;
// Set when the next draw should post DidCommitAndDrawFrame to the main
// thread.
......
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