Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: cc/trees/proxy_impl.cc

Issue 2000493002: cc: Fix overwriting of commit completion event in MFBA mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/proxy_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/proxy_impl.h" 5 #include "cc/trees/proxy_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 new ProxyImpl(channel_impl, layer_tree_host, task_runner_provider, 44 new ProxyImpl(channel_impl, layer_tree_host, task_runner_provider,
45 std::move(external_begin_frame_source))); 45 std::move(external_begin_frame_source)));
46 } 46 }
47 47
48 ProxyImpl::ProxyImpl( 48 ProxyImpl::ProxyImpl(
49 ChannelImpl* channel_impl, 49 ChannelImpl* channel_impl,
50 LayerTreeHost* layer_tree_host, 50 LayerTreeHost* layer_tree_host,
51 TaskRunnerProvider* task_runner_provider, 51 TaskRunnerProvider* task_runner_provider,
52 std::unique_ptr<BeginFrameSource> external_begin_frame_source) 52 std::unique_ptr<BeginFrameSource> external_begin_frame_source)
53 : layer_tree_host_id_(layer_tree_host->id()), 53 : layer_tree_host_id_(layer_tree_host->id()),
54 next_commit_waits_for_activation_(false), 54 commit_completion_waits_for_activation_(false),
55 commit_completion_event_(nullptr), 55 commit_completion_event_(nullptr),
56 activation_completion_event_(nullptr),
56 next_frame_is_newly_committed_frame_(false), 57 next_frame_is_newly_committed_frame_(false),
57 inside_draw_(false), 58 inside_draw_(false),
58 input_throttled_until_commit_(false), 59 input_throttled_until_commit_(false),
59 task_runner_provider_(task_runner_provider), 60 task_runner_provider_(task_runner_provider),
60 smoothness_priority_expiration_notifier_( 61 smoothness_priority_expiration_notifier_(
61 task_runner_provider->ImplThreadTaskRunner(), 62 task_runner_provider->ImplThreadTaskRunner(),
62 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), 63 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)),
63 base::TimeDelta::FromSecondsD( 64 base::TimeDelta::FromSecondsD(
64 kSmoothnessTakesPriorityExpirationDelay)), 65 kSmoothnessTakesPriorityExpirationDelay)),
65 external_begin_frame_source_(std::move(external_begin_frame_source)), 66 external_begin_frame_source_(std::move(external_begin_frame_source)),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 bool* main_frame_will_happen) { 235 bool* main_frame_will_happen) {
235 DCHECK(IsImplThread()); 236 DCHECK(IsImplThread());
236 if (layer_tree_host_impl_->output_surface()) { 237 if (layer_tree_host_impl_->output_surface()) {
237 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen(); 238 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen();
238 } else { 239 } else {
239 *main_frame_will_happen = false; 240 *main_frame_will_happen = false;
240 } 241 }
241 completion->Signal(); 242 completion->Signal();
242 } 243 }
243 244
245 void ProxyImpl::BlockNotifyReadyToActivateForTesting(bool block) {
246 DCHECK(IsImplThread());
247 layer_tree_host_impl_->BlockNotifyReadyToActivateForTesting(block);
248 }
249
244 void ProxyImpl::StartCommitOnImpl(CompletionEvent* completion, 250 void ProxyImpl::StartCommitOnImpl(CompletionEvent* completion,
245 LayerTreeHost* layer_tree_host, 251 LayerTreeHost* layer_tree_host,
246 base::TimeTicks main_thread_start_time, 252 base::TimeTicks main_thread_start_time,
247 bool hold_commit_for_activation) { 253 bool hold_commit_for_activation) {
248 TRACE_EVENT0("cc", "ProxyImpl::StartCommitOnImplThread"); 254 TRACE_EVENT0("cc", "ProxyImpl::StartCommitOnImplThread");
249 DCHECK(!commit_completion_event_); 255 DCHECK(!commit_completion_event_);
250 DCHECK(IsImplThread() && IsMainThreadBlocked()); 256 DCHECK(IsImplThread() && IsMainThreadBlocked());
251 DCHECK(scheduler_); 257 DCHECK(scheduler_);
252 DCHECK(scheduler_->CommitPending()); 258 DCHECK(scheduler_->CommitPending());
253 259
254 if (hold_commit_for_activation) {
255 // This commit may be aborted. Store the value for
256 // hold_commit_for_activation so that whenever the next commit is started,
257 // the main thread will be unblocked only after pending tree activation.
258 next_commit_waits_for_activation_ = hold_commit_for_activation;
259 }
260
261 if (!layer_tree_host_impl_) { 260 if (!layer_tree_host_impl_) {
262 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree", 261 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree",
263 TRACE_EVENT_SCOPE_THREAD); 262 TRACE_EVENT_SCOPE_THREAD);
264 completion->Signal(); 263 completion->Signal();
265 return; 264 return;
266 } 265 }
267 266
268 // Ideally, we should inform to impl thread when BeginMainFrame is started. 267 // Ideally, we should inform to impl thread when BeginMainFrame is started.
269 // But, we can avoid a PostTask in here. 268 // But, we can avoid a PostTask in here.
270 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); 269 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time);
270
271 commit_completion_event_ = completion; 271 commit_completion_event_ = completion;
272 // This commit may be aborted. Store the value for hold_commit_for_activation
enne (OOO) 2016/05/20 18:26:12 Is this comment true? It seems like one you get pa
sunnyps 2016/05/20 20:49:36 Done.
273 // so that whenever the next commit is started, the main thread will be
274 // unblocked only after pending tree activation.
275 commit_completion_waits_for_activation_ = hold_commit_for_activation;
276
272 DCHECK(!blocked_main_commit().layer_tree_host); 277 DCHECK(!blocked_main_commit().layer_tree_host);
273 blocked_main_commit().layer_tree_host = layer_tree_host; 278 blocked_main_commit().layer_tree_host = layer_tree_host;
274 scheduler_->NotifyReadyToCommit(); 279 scheduler_->NotifyReadyToCommit();
275 } 280 }
276 281
277 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() { 282 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() {
278 DCHECK(IsImplThread()); 283 DCHECK(IsImplThread());
279 channel_impl_->SetRendererCapabilitiesMainCopy( 284 channel_impl_->SetRendererCapabilitiesMainCopy(
280 layer_tree_host_impl_->GetRendererCapabilities() 285 layer_tree_host_impl_->GetRendererCapabilities()
281 .MainThreadCapabilities()); 286 .MainThreadCapabilities());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 base::TimeDelta delay) { 444 base::TimeDelta delay) {
440 DCHECK(IsImplThread()); 445 DCHECK(IsImplThread());
441 task_runner_provider_->ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, 446 task_runner_provider_->ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE,
442 task, delay); 447 task, delay);
443 } 448 }
444 449
445 void ProxyImpl::DidActivateSyncTree() { 450 void ProxyImpl::DidActivateSyncTree() {
446 TRACE_EVENT0("cc", "ProxyImpl::DidActivateSyncTreeOnImplThread"); 451 TRACE_EVENT0("cc", "ProxyImpl::DidActivateSyncTreeOnImplThread");
447 DCHECK(IsImplThread()); 452 DCHECK(IsImplThread());
448 453
449 if (next_commit_waits_for_activation_) { 454 if (activation_completion_event_) {
450 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 455 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
451 TRACE_EVENT_SCOPE_THREAD); 456 TRACE_EVENT_SCOPE_THREAD);
452 DCHECK(commit_completion_event_); 457 activation_completion_event_->Signal();
453 commit_completion_event_->Signal(); 458 activation_completion_event_ = nullptr;
454 commit_completion_event_ = nullptr;
455 next_commit_waits_for_activation_ = false;
456 } 459 }
457 } 460 }
458 461
459 void ProxyImpl::WillPrepareTiles() { 462 void ProxyImpl::WillPrepareTiles() {
460 DCHECK(IsImplThread()); 463 DCHECK(IsImplThread());
461 scheduler_->WillPrepareTiles(); 464 scheduler_->WillPrepareTiles();
462 } 465 }
463 466
464 void ProxyImpl::DidPrepareTiles() { 467 void ProxyImpl::DidPrepareTiles() {
465 DCHECK(IsImplThread()); 468 DCHECK(IsImplThread());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 layer_tree_host_impl_->BeginCommit(); 545 layer_tree_host_impl_->BeginCommit();
543 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( 546 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread(
544 layer_tree_host_impl_.get()); 547 layer_tree_host_impl_.get());
545 548
546 // Remove the LayerTreeHost reference before the completion event is signaled 549 // Remove the LayerTreeHost reference before the completion event is signaled
547 // and cleared. This is necessary since blocked_main_commit() allows access 550 // and cleared. This is necessary since blocked_main_commit() allows access
548 // only while we have the completion event to ensure the main thread is 551 // only while we have the completion event to ensure the main thread is
549 // blocked for a commit. 552 // blocked for a commit.
550 blocked_main_commit().layer_tree_host = nullptr; 553 blocked_main_commit().layer_tree_host = nullptr;
551 554
552 if (next_commit_waits_for_activation_) { 555 if (commit_completion_waits_for_activation_) {
553 // For some layer types in impl-side painting, the commit is held until 556 // For some layer types in impl-side painting, the commit is held until the
554 // the sync tree is activated. It's also possible that the 557 // sync tree is activated. It's also possible that the sync tree has
555 // sync tree has already activated if there was no work to be done. 558 // already activated if there was no work to be done.
556 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 559 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
560 commit_completion_waits_for_activation_ = false;
561 activation_completion_event_ = commit_completion_event_;
557 } else { 562 } else {
558 commit_completion_event_->Signal(); 563 commit_completion_event_->Signal();
559 commit_completion_event_ = nullptr;
560 } 564 }
565 commit_completion_event_ = nullptr;
561 566
562 scheduler_->DidCommit(); 567 scheduler_->DidCommit();
563 568
564 // Delay this step until afer the main thread has been released as it's 569 // Delay this step until afer the main thread has been released as it's
565 // often a good bit of work to update the tree and prepare the new frame. 570 // often a good bit of work to update the tree and prepare the new frame.
566 layer_tree_host_impl_->CommitComplete(); 571 layer_tree_host_impl_->CommitComplete();
567 572
568 SetInputThrottledUntilCommitOnImpl(false); 573 SetInputThrottledUntilCommitOnImpl(false);
569 574
570 next_frame_is_newly_committed_frame_ = true; 575 next_frame_is_newly_committed_frame_ = true;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 bool ProxyImpl::IsMainThreadBlocked() const { 672 bool ProxyImpl::IsMainThreadBlocked() const {
668 return task_runner_provider_->IsMainThreadBlocked(); 673 return task_runner_provider_->IsMainThreadBlocked();
669 } 674 }
670 675
671 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { 676 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() {
672 DCHECK(IsMainThreadBlocked() && commit_completion_event_); 677 DCHECK(IsMainThreadBlocked() && commit_completion_event_);
673 return main_thread_blocked_commit_vars_unsafe_; 678 return main_thread_blocked_commit_vars_unsafe_;
674 } 679 }
675 680
676 } // namespace cc 681 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/proxy_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698