diff options
author | ananta <ananta@chromium.org> | 2015-06-10 06:02:11 +0900 |
---|---|---|
committer | Qijiang Fan <fqj@google.com> | 2020-06-04 19:04:32 +0900 |
commit | 5607e7cc4e47311ed5ebab24586841d946234568 (patch) | |
tree | 4b87acd759c0712a79bd58950f6055c6942b434c /base/message_loop/incoming_task_queue.cc | |
parent | 61f34bbf577bf179d3f7312495654b8be48a49ff (diff) | |
download | libchrome-5607e7cc4e47311ed5ebab24586841d946234568.tar.gz |
Don't peek messages in the MessagePumpForUI class when we receive our kMsgHaveWork message.
Currently the MessagePumpForUI class peeks Windows messages when we receive the kMsgHaveWork message in
our main message loop and in nested modal loops. This is because the posted message starves the message loop
of input and other lower priority messages. While this is ok for the main message loop our peeking and dispatching
messages in nested loops is wrong and violates the silent contract where in the nested loop should be the one peeking
and dispatching messages.
To fix this the approach we are taking is to create a worker thread which uses a waitable timer of 3 ms which posts
the kMsgHaveWork message to the main loop when the timer fires. As a result we can safely delete all the code
in the MessagePumpForUI::ScheduleWork function and simplify the ProcessPumpReplacementMessage function.
The MessagePumpForUI::ScheduleWork function now checks the delay for the task at the head of the queue
If it is 0 then we post the message right away as it is a regular task. Added functions (GetNewlyAddedTaskDelay) to the MessagePump::Delegate class and the IncomingTaskQueue for this.
The other change here is to change the GPU process to use the IO message pump by default and use the UI pump only
if we are using opengl. Reason being this patch causes a delay in processing tasks due to the worker thread which
causes tests like webgl_conformance to fail. We will continue working on addressing this over the coming days.
BUG=492837
R=cpu
Review URL: https://codereview.chromium.org/1156503005
Cr-Commit-Position: refs/heads/master@{#333572}
CrOS-Libchrome-Original-Commit: b8e126c8b532b1327f38afe2bdf59aa5ff933971
Diffstat (limited to 'base/message_loop/incoming_task_queue.cc')
-rw-r--r-- | base/message_loop/incoming_task_queue.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/base/message_loop/incoming_task_queue.cc b/base/message_loop/incoming_task_queue.cc index 5e9a4613da..642222efc8 100644 --- a/base/message_loop/incoming_task_queue.cc +++ b/base/message_loop/incoming_task_queue.cc @@ -119,6 +119,11 @@ void IncomingTaskQueue::StartScheduling() { ScheduleWork(); } +TimeTicks IncomingTaskQueue::GetNewlyAddedTaskDelay() { + return !incoming_queue_.empty() ? incoming_queue_.front().delayed_run_time : + TimeTicks(); +} + IncomingTaskQueue::~IncomingTaskQueue() { // Verify that WillDestroyCurrentMessageLoop() has been called. DCHECK(!message_loop_); |