Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Issue 1156503005: Don't peek messages in the MessagePumpForUI class when we receive our kMsgHaveWork message. (Closed)

Created:
5 years, 6 months ago by ananta
Modified:
5 years, 6 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, sadrul
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+146 lines, -58 lines) Patch
M base/message_loop/incoming_task_queue.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download
M base/message_loop/incoming_task_queue.cc View 1 2 3 4 5 6 7 8 1 chunk +5 lines, -0 lines 0 comments Download
M base/message_loop/message_loop.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M base/message_loop/message_loop.cc View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -0 lines 0 comments Download
M base/message_loop/message_pump.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download
M base/message_loop/message_pump_win.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +31 lines, -0 lines 0 comments Download
M base/message_loop/message_pump_win.cc View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +83 lines, -55 lines 0 comments Download
M content/gpu/gpu_main.cc View 1 2 3 4 5 6 7 1 chunk +16 lines, -3 lines 0 comments Download

Messages

Total messages: 44 (13 generated)
ananta
5 years, 6 months ago (2015-05-28 02:26:11 UTC) #1
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc#newcode448 base/message_loop/message_pump_win.cc:448: if (ret == WAIT_OBJECT_0) { instead of using exit_ui_worker_thread_ ...
5 years, 6 months ago (2015-05-28 22:45:12 UTC) #2
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc#newcode95 base/message_loop/message_pump_win.cc:95: ui_worker_thread_.reset(new base::Thread("UI Pump Worker thread")); can we do this ...
5 years, 6 months ago (2015-05-28 22:45:51 UTC) #3
ananta
https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/20001/base/message_loop/message_pump_win.cc#newcode95 base/message_loop/message_pump_win.cc:95: ui_worker_thread_.reset(new base::Thread("UI Pump Worker thread")); On 2015/05/28 22:45:51, cpu ...
5 years, 6 months ago (2015-05-29 00:51:29 UTC) #4
jbauman
Seems nice, though I'm a bit worried that processing 1 task every 3 ms might ...
5 years, 6 months ago (2015-05-29 22:47:44 UTC) #6
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/1156503005/diff/40001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/40001/base/message_loop/message_pump_win.cc#newcode448 base/message_loop/message_pump_win.cc:448: HANDLE objects[] = {ui_worker_thread_signal_.handle(), timer.Get()}; I don't think you ...
5 years, 6 months ago (2015-06-02 00:17:27 UTC) #8
jar (doing other things)
Drive-by commentary (invited by cpu). I suspect that this approach will put a hard limit ...
5 years, 6 months ago (2015-06-02 00:35:16 UTC) #10
ananta
On 2015/06/02 00:35:16, jar (doing other things) wrote: > Drive-by commentary (invited by cpu). > ...
5 years, 6 months ago (2015-06-02 00:58:23 UTC) #11
jar (doing other things)
On 2015/06/02 00:58:23, ananta wrote: > On 2015/06/02 00:35:16, jar (doing other things) wrote: > ...
5 years, 6 months ago (2015-06-02 02:41:06 UTC) #12
ananta
On 2015/06/02 02:41:06, jar (doing other things) wrote: > On 2015/06/02 00:58:23, ananta wrote: > ...
5 years, 6 months ago (2015-06-02 02:45:24 UTC) #13
cpu_(ooo_6.6-7.5)
I made another comment in PS3 about the need for the event, let me know.
5 years, 6 months ago (2015-06-02 19:34:19 UTC) #14
cpu_(ooo_6.6-7.5)
lgtm To be fair, the timer fire rate is something that seems we are not ...
5 years, 6 months ago (2015-06-03 00:57:11 UTC) #15
ananta
https://codereview.chromium.org/1156503005/diff/40001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/40001/base/message_loop/message_pump_win.cc#newcode448 base/message_loop/message_pump_win.cc:448: HANDLE objects[] = {ui_worker_thread_signal_.handle(), timer.Get()}; On 2015/06/02 00:17:27, cpu ...
5 years, 6 months ago (2015-06-03 01:27:30 UTC) #16
ananta
5 years, 6 months ago (2015-06-04 02:48:32 UTC) #18
Ken Russell (switch to Gerrit)
gpu_main.cc LGTM. Would be good to get feedback from geofflang@ too.
5 years, 6 months ago (2015-06-04 21:36:56 UTC) #19
Geoff Lang
lgtm
5 years, 6 months ago (2015-06-05 13:40:21 UTC) #20
Geoff Lang
https://codereview.chromium.org/1156503005/diff/140001/content/gpu/gpu_main.cc File content/gpu/gpu_main.cc (right): https://codereview.chromium.org/1156503005/diff/140001/content/gpu/gpu_main.cc#newcode166 content/gpu/gpu_main.cc:166: // TODO(ananta) : Recent changes to the UI message ...
5 years, 6 months ago (2015-06-05 13:40:35 UTC) #21
ananta
cpu, please take a peek at the latest patch. I added code to process posted ...
5 years, 6 months ago (2015-06-06 00:24:18 UTC) #22
scottmg
(temporary stand in for cpu by request) I don't really understand the finer details, but ...
5 years, 6 months ago (2015-06-08 21:43:31 UTC) #24
ananta
https://codereview.chromium.org/1156503005/diff/160001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/160001/base/message_loop/message_pump_win.cc#newcode127 base/message_loop/message_pump_win.cc:127: due_time.QuadPart = -30000; On 2015/06/08 21:43:31, scottmg wrote: > ...
5 years, 6 months ago (2015-06-08 21:46:55 UTC) #25
scottmg
ok, lgtm
5 years, 6 months ago (2015-06-08 21:50:56 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1156503005/160001
5 years, 6 months ago (2015-06-08 22:28:28 UTC) #29
scottmg
https://codereview.chromium.org/1156503005/diff/180001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/180001/base/message_loop/message_pump_win.cc#newcode126 base/message_loop/message_pump_win.cc:126: // timer is dependent on timeBeginPeriod being called. mention ...
5 years, 6 months ago (2015-06-09 00:15:29 UTC) #31
ananta
https://codereview.chromium.org/1156503005/diff/180001/base/message_loop/message_pump_win.cc File base/message_loop/message_pump_win.cc (right): https://codereview.chromium.org/1156503005/diff/180001/base/message_loop/message_pump_win.cc#newcode126 base/message_loop/message_pump_win.cc:126: // timer is dependent on timeBeginPeriod being called. On ...
5 years, 6 months ago (2015-06-09 00:27:54 UTC) #32
scottmg
lgtm https://codereview.chromium.org/1156503005/diff/200001/base/message_loop/message_pump_win.h File base/message_loop/message_pump_win.h (right): https://codereview.chromium.org/1156503005/diff/200001/base/message_loop/message_pump_win.h#newcode158 base/message_loop/message_pump_win.h:158: void SetWakeupTimer(int64 delay); nit; "delay_ms" (and in the ...
5 years, 6 months ago (2015-06-09 16:22:42 UTC) #33
ananta
https://codereview.chromium.org/1156503005/diff/200001/base/message_loop/message_pump_win.h File base/message_loop/message_pump_win.h (right): https://codereview.chromium.org/1156503005/diff/200001/base/message_loop/message_pump_win.h#newcode158 base/message_loop/message_pump_win.h:158: void SetWakeupTimer(int64 delay); On 2015/06/09 16:22:42, scottmg wrote: > ...
5 years, 6 months ago (2015-06-09 18:25:44 UTC) #34
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1156503005/220001
5 years, 6 months ago (2015-06-09 18:26:06 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1156503005/240001
5 years, 6 months ago (2015-06-09 19:21:40 UTC) #41
commit-bot: I haz the power
Committed patchset #13 (id:240001)
5 years, 6 months ago (2015-06-09 21:02:20 UTC) #42
commit-bot: I haz the power
Patchset 13 (id:??) landed as https://crrev.com/b8e126c8b532b1327f38afe2bdf59aa5ff933971 Cr-Commit-Position: refs/heads/master@{#333572}
5 years, 6 months ago (2015-06-09 21:03:34 UTC) #43
kjellander_chromium
5 years, 6 months ago (2015-06-10 07:53:25 UTC) #44
Message was sent while issue was closed.
A revert of this CL (patchset #13 id:240001) has been created in
https://codereview.chromium.org/1163423006/ by kjellander@chromium.org.

The reason for reverting is: I suspect this CL breaks Windows 8
content_unittests, as it's listed both in 
https://build.chromium.org/p/chromium.fyi/builders/Win8%20Tests%20%281%29/bui...
and our WebRTC-specific waterfall:
https://build.chromium.org/p/chromium.webrtc/builders/Win8%20Tester/builds/14164

I'll try to reland if it turns out not to solve the breakage..

Powered by Google App Engine
This is Rietveld 408576698