Commit baa31e39 authored by jdduke's avatar jdduke Committed by Commit bot

More aggressively yield when awaiting touchstart response

Change the RendererScheduler's |ShouldYieldForHighPriorityWork| query
to always return true if we are awaiting touchstart response, regardless
of whether any high-priority work has been queued. This should facilitate
more aggressive yielding immediately after touchstart, reducing the risk
of long-running tasks interrupting dispatch of the subsequent touchmove.

BUG=452956

Review URL: https://codereview.chromium.org/933293004

Cr-Commit-Position: refs/heads/master@{#317130}
parent 060f1487
...@@ -190,14 +190,25 @@ bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { ...@@ -190,14 +190,25 @@ bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() {
return false; return false;
MaybeUpdatePolicy(); MaybeUpdatePolicy();
// We only yield if we are in the touchstart/compositor priority and there // We only yield if we are in the compositor priority and there is compositor
// is input/compositor work outstanding. Note: even though the control queue // work outstanding, or if we are in the touchstart response priority.
// is higher priority we don't yield for it since these tasks are not // Note: even though the control queue is higher priority we don't yield for
// user-provided work and they are only intended to run before the next task, // it since these tasks are not user-provided work and they are only intended
// not interrupt the tasks. // to run before the next task, not interrupt the tasks.
return (SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY || switch (SchedulerPolicy()) {
SchedulerPolicy() == TOUCHSTART_PRIORITY_POLICY) && case NORMAL_PRIORITY_POLICY:
!task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); return false;
case COMPOSITOR_PRIORITY_POLICY:
return !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE);
case TOUCHSTART_PRIORITY_POLICY:
return true;
default:
NOTREACHED();
return false;
}
} }
void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback(
......
...@@ -798,6 +798,14 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) { ...@@ -798,6 +798,14 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) {
// We should be able to switch to compositor priority mid-task. // We should be able to switch to compositor priority mid-task.
EXPECT_FALSE(should_yield_before); EXPECT_FALSE(should_yield_before);
EXPECT_TRUE(should_yield_after); EXPECT_TRUE(should_yield_after);
// Receiving a touchstart should immediately trigger yielding, even if
// there's no immediately pending work in the compositor queue.
EXPECT_FALSE(scheduler_->ShouldYieldForHighPriorityWork());
scheduler_->DidReceiveInputEventOnCompositorThread(
FakeInputEvent(blink::WebInputEvent::TouchStart));
EXPECT_TRUE(scheduler_->ShouldYieldForHighPriorityWork());
RunUntilIdle();
} }
} // namespace content } // namespace content
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