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() {
return false;
MaybeUpdatePolicy();
// We only yield if we are in the touchstart/compositor priority and there
// is input/compositor work outstanding. Note: even though the control queue
// is higher priority we don't yield for it since these tasks are not
// user-provided work and they are only intended to run before the next task,
// not interrupt the tasks.
return (SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY ||
SchedulerPolicy() == TOUCHSTART_PRIORITY_POLICY) &&
!task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE);
// We only yield if we are in the compositor priority and there is compositor
// work outstanding, or if we are in the touchstart response priority.
// Note: even though the control queue is higher priority we don't yield for
// it since these tasks are not user-provided work and they are only intended
// to run before the next task, not interrupt the tasks.
switch (SchedulerPolicy()) {
case NORMAL_PRIORITY_POLICY:
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(
......
......@@ -798,6 +798,14 @@ TEST_F(RendererSchedulerImplTest, TestShouldYield) {
// We should be able to switch to compositor priority mid-task.
EXPECT_FALSE(should_yield_before);
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
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