DescriptionDon'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
Committed: https://crrev.com/b8e126c8b532b1327f38afe2bdf59aa5ff933971
Cr-Commit-Position: refs/heads/master@{#333572}
Patch Set 1 #Patch Set 2 : Fix indent #
Total comments: 6
Patch Set 3 : Use an autoreset event to signal the worker that we have tasks to process #
Total comments: 6
Patch Set 4 : Address cpu review comments #Patch Set 5 : Attempt to fix windows trybots redness #Patch Set 6 : Remove the event and use the timer to indicate presence of tasks #
Total comments: 4
Patch Set 7 : Address cpu review comments #Patch Set 8 : Use the IO message pump in the GPU process by default #
Total comments: 1
Patch Set 9 : Provide a way to process posted tasks quicker #
Total comments: 4
Patch Set 10 : Make the waitable timer a one shot timer as was originally intended #
Total comments: 4
Patch Set 11 : Address scottmg review comments by moving the waitable timer call to its own function #
Total comments: 2
Patch Set 12 : Rename the delay parameter to delay_ms to clear things up #Patch Set 13 : Fix build error #
Messages
Total messages: 44 (13 generated)
|