Commit f4b7e5bd authored by Shubhie Panicker's avatar Shubhie Panicker Committed by Commit Bot

Per frame loading task queue should not be stopped by MTS.

Also ensure throttling state is conditioned on keep_active.
Clean up a TODO in FS.

Bug: 820634
Change-Id: I553fd6331593d3a3ee4fd408373926eaedfb749d
Reviewed-on: https://chromium-review.googlesource.com/996914
Commit-Queue: Shubhie Panicker <panicker@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549308}
parent 4405a297
...@@ -515,10 +515,8 @@ void FrameSchedulerImpl::SetPageVisibility( ...@@ -515,10 +515,8 @@ void FrameSchedulerImpl::SetPageVisibility(
page_visibility_ = page_visibility; page_visibility_ = page_visibility;
if (page_visibility_ == PageVisibilityState::kVisible) if (page_visibility_ == PageVisibilityState::kVisible)
page_frozen_ = false; // visible page must not be frozen. page_frozen_ = false; // visible page must not be frozen.
// TODO(altimin): Avoid having to call all these methods here.
UpdateTaskQueues(); UpdateTaskQueues();
UpdateTaskQueueThrottling(); UpdateTaskQueueThrottling();
UpdateThrottlingState();
} }
bool FrameSchedulerImpl::IsPageVisible() const { bool FrameSchedulerImpl::IsPageVisible() const {
...@@ -538,7 +536,6 @@ void FrameSchedulerImpl::SetPageFrozen(bool frozen) { ...@@ -538,7 +536,6 @@ void FrameSchedulerImpl::SetPageFrozen(bool frozen) {
DCHECK(!frozen || page_visibility_ == PageVisibilityState::kHidden); DCHECK(!frozen || page_visibility_ == PageVisibilityState::kHidden);
page_frozen_ = frozen; page_frozen_ = frozen;
UpdateTaskQueues(); UpdateTaskQueues();
UpdateThrottlingState();
} }
void FrameSchedulerImpl::SetKeepActive(bool keep_active) { void FrameSchedulerImpl::SetKeepActive(bool keep_active) {
...@@ -557,6 +554,7 @@ void FrameSchedulerImpl::UpdateTaskQueues() { ...@@ -557,6 +554,7 @@ void FrameSchedulerImpl::UpdateTaskQueues() {
UpdateTaskQueue(deferrable_task_queue_, UpdateTaskQueue(deferrable_task_queue_,
deferrable_queue_enabled_voter_.get()); deferrable_queue_enabled_voter_.get());
UpdateTaskQueue(pausable_task_queue_, pausable_queue_enabled_voter_.get()); UpdateTaskQueue(pausable_task_queue_, pausable_queue_enabled_voter_.get());
UpdateThrottlingState();
} }
void FrameSchedulerImpl::UpdateTaskQueue( void FrameSchedulerImpl::UpdateTaskQueue(
...@@ -584,7 +582,7 @@ void FrameSchedulerImpl::UpdateThrottlingState() { ...@@ -584,7 +582,7 @@ void FrameSchedulerImpl::UpdateThrottlingState() {
FrameScheduler::ThrottlingState FrameSchedulerImpl::CalculateThrottlingState() FrameScheduler::ThrottlingState FrameSchedulerImpl::CalculateThrottlingState()
const { const {
if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled() && if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled() &&
page_frozen_) { page_frozen_ && !keep_active_) {
DCHECK(page_visibility_ == PageVisibilityState::kHidden); DCHECK(page_visibility_ == PageVisibilityState::kHidden);
return FrameScheduler::ThrottlingState::kStopped; return FrameScheduler::ThrottlingState::kStopped;
} }
......
...@@ -1538,10 +1538,11 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { ...@@ -1538,10 +1538,11 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
main_thread_only().expensive_task_policy = expensive_task_policy; main_thread_only().expensive_task_policy = expensive_task_policy;
if (main_thread_only().stopped_when_backgrounded) { if (main_thread_only().stopped_when_backgrounded) {
// TODO(panicker): Remove this, as it is controlled at
// FrameScheduler. This is currently needed to avoid early out.
new_policy.timer_queue_policy().is_stopped = true; new_policy.timer_queue_policy().is_stopped = true;
if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled())
new_policy.loading_queue_policy().is_stopped = true;
} }
if (main_thread_only().renderer_pause_count != 0) { if (main_thread_only().renderer_pause_count != 0) {
new_policy.loading_queue_policy().is_paused = true; new_policy.loading_queue_policy().is_paused = true;
new_policy.timer_queue_policy().is_paused = true; new_policy.timer_queue_policy().is_paused = true;
......
...@@ -2575,59 +2575,6 @@ TEST_F(RendererSchedulerImplTest, TestRendererBackgroundedTimerSuspension) { ...@@ -2575,59 +2575,6 @@ TEST_F(RendererSchedulerImplTest, TestRendererBackgroundedTimerSuspension) {
EXPECT_THAT(run_order, testing::ElementsAre(std::string("T6"))); EXPECT_THAT(run_order, testing::ElementsAre(std::string("T6")));
} }
TEST_F(RendererSchedulerImplTest, TestRendererBackgroundedLoadingSuspension) {
ScopedStopLoadingInBackgroundForTest stop_loading_enabler(true);
scheduler_->SetStoppingWhenBackgroundedEnabled(true);
std::vector<std::string> run_order;
PostTestTasks(&run_order, "L1 L2");
base::TimeTicks now;
// The background signal will not immediately suspend the loading queue.
scheduler_->SetRendererBackgrounded(true);
now += base::TimeDelta::FromMilliseconds(1100);
clock_.SetNowTicks(now);
RunUntilIdle();
EXPECT_THAT(run_order,
testing::ElementsAre(std::string("L1"), std::string("L2")));
run_order.clear();
PostTestTasks(&run_order, "L3");
now += base::TimeDelta::FromSeconds(1);
clock_.SetNowTicks(now);
RunUntilIdle();
EXPECT_THAT(run_order, testing::ElementsAre(std::string("L3")));
// Advance the time until after the scheduled loading queue suspension.
now = base::TimeTicks() + delay_for_background_tab_stopping() +
base::TimeDelta::FromMilliseconds(10);
run_order.clear();
clock_.SetNowTicks(now);
RunUntilIdle();
ASSERT_TRUE(run_order.empty());
// Loading tasks should be paused until the foregrounded signal.
PostTestTasks(&run_order, "L4 L5");
now += base::TimeDelta::FromSeconds(10);
clock_.SetNowTicks(now);
RunUntilIdle();
EXPECT_THAT(run_order, testing::ElementsAre());
scheduler_->SetRendererBackgrounded(false);
RunUntilIdle();
EXPECT_THAT(run_order,
testing::ElementsAre(std::string("L4"), std::string("L5")));
// Subsequent loading tasks should fire as usual.
run_order.clear();
PostTestTasks(&run_order, "L6");
RunUntilIdle();
EXPECT_THAT(run_order, testing::ElementsAre(std::string("L6")));
}
TEST_F(RendererSchedulerImplTest, TEST_F(RendererSchedulerImplTest,
ExpensiveLoadingTasksNotBlockedTillFirstBeginMainFrame) { ExpensiveLoadingTasksNotBlockedTillFirstBeginMainFrame) {
std::vector<std::string> run_order; std::vector<std::string> run_order;
......
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