| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 // we have both a pending tree and an active tree. | 1972 // we have both a pending tree and an active tree. |
| 1973 client_->Reset(); | 1973 client_->Reset(); |
| 1974 EXPECT_FALSE(scheduler_->CommitPending()); | 1974 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1975 scheduler_->SetNeedsBeginMainFrame(); | 1975 scheduler_->SetNeedsBeginMainFrame(); |
| 1976 EXPECT_SCOPED(AdvanceFrame()); | 1976 EXPECT_SCOPED(AdvanceFrame()); |
| 1977 EXPECT_FALSE(scheduler_->CommitPending()); | 1977 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1978 task_runner().RunPendingTasks(); // Run posted deadline. | 1978 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1979 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1979 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 TEST_F(SchedulerTest, | |
| 1983 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { | |
| 1984 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | |
| 1985 // thread. This prevents the scheduler from receiving any pending swap acks. | |
| 1986 | |
| 1987 // This particular test makes sure we do not send a BeginMainFrame while | |
| 1988 // swap trottled and we have a pending tree and active tree that | |
| 1989 // still needs to be drawn for the first time. | |
| 1990 | |
| 1991 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1992 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | |
| 1993 scheduler_settings_.main_frame_before_activation_enabled = true; | |
| 1994 SetUpScheduler(true); | |
| 1995 | |
| 1996 // Disables automatic swap acks so this test can force swap ack throttling | |
| 1997 // to simulate a blocked Browser ui thread. | |
| 1998 client_->SetAutomaticSwapAck(false); | |
| 1999 | |
| 2000 // Start a new commit in main-thread high latency mode and hold off on | |
| 2001 // activation. | |
| 2002 client_->Reset(); | |
| 2003 EXPECT_FALSE(scheduler_->CommitPending()); | |
| 2004 scheduler_->SetNeedsBeginMainFrame(); | |
| 2005 scheduler_->SetNeedsRedraw(); | |
| 2006 EXPECT_SCOPED(AdvanceFrame()); | |
| 2007 EXPECT_TRUE(scheduler_->CommitPending()); | |
| 2008 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 2009 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 2010 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 2011 scheduler_->DidSwapBuffersComplete(); | |
| 2012 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | |
| 2013 scheduler_->NotifyReadyToCommit(); | |
| 2014 EXPECT_FALSE(scheduler_->CommitPending()); | |
| 2015 EXPECT_ACTION("AddObserver(this)", client_, 0, 5); | |
| 2016 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | |
| 2017 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | |
| 2018 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 5); | |
| 2019 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 5); | |
| 2020 | |
| 2021 // Start another commit while we still have aa pending tree. | |
| 2022 // Enter a swap throttled state. | |
| 2023 client_->Reset(); | |
| 2024 EXPECT_FALSE(scheduler_->CommitPending()); | |
| 2025 scheduler_->SetNeedsBeginMainFrame(); | |
| 2026 scheduler_->SetNeedsRedraw(); | |
| 2027 EXPECT_SCOPED(AdvanceFrame()); | |
| 2028 EXPECT_TRUE(scheduler_->CommitPending()); | |
| 2029 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 2030 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 2031 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 2032 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | |
| 2033 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | |
| 2034 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 3); | |
| 2035 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); | |
| 2036 | |
| 2037 // Can't commit yet because there's still a pending tree. | |
| 2038 client_->Reset(); | |
| 2039 scheduler_->NotifyReadyToCommit(); | |
| 2040 EXPECT_NO_ACTION(client_); | |
| 2041 | |
| 2042 // Activate the pending tree, which also unblocks the commit immediately. | |
| 2043 client_->Reset(); | |
| 2044 scheduler_->NotifyReadyToActivate(); | |
| 2045 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2); | |
| 2046 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2); | |
| 2047 | |
| 2048 // Make sure we do not send a BeginMainFrame while swap throttled and | |
| 2049 // we have both a pending tree and an active tree that still needs | |
| 2050 // it's first draw. | |
| 2051 client_->Reset(); | |
| 2052 EXPECT_FALSE(scheduler_->CommitPending()); | |
| 2053 scheduler_->SetNeedsBeginMainFrame(); | |
| 2054 EXPECT_SCOPED(AdvanceFrame()); | |
| 2055 EXPECT_FALSE(scheduler_->CommitPending()); | |
| 2056 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 2057 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 2058 } | |
| 2059 | |
| 2060 TEST_F( | 1982 TEST_F( |
| 2061 SchedulerTest, | 1983 SchedulerTest, |
| 2062 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { | 1984 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { |
| 2063 // This verifies we don't block commits longer than we need to | 1985 // This verifies we don't block commits longer than we need to |
| 2064 // for performance reasons - not deadlock reasons. | 1986 // for performance reasons - not deadlock reasons. |
| 2065 | 1987 |
| 2066 // Since we are simulating a long commit, set up a client with draw duration | 1988 // Since we are simulating a long commit, set up a client with draw duration |
| 2067 // estimates that prevent skipping main frames to get to low latency mode. | 1989 // estimates that prevent skipping main frames to get to low latency mode. |
| 2068 scheduler_settings_.use_external_begin_frame_source = true; | 1990 scheduler_settings_.use_external_begin_frame_source = true; |
| 2069 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1991 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3773 } | 3695 } |
| 3774 | 3696 |
| 3775 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3697 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3776 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3698 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3777 SMOOTHNESS_TAKES_PRIORITY, | 3699 SMOOTHNESS_TAKES_PRIORITY, |
| 3778 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3700 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3779 } | 3701 } |
| 3780 | 3702 |
| 3781 } // namespace | 3703 } // namespace |
| 3782 } // namespace cc | 3704 } // namespace cc |
| OLD | NEW |