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

Unified Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2342603003: Don't process more than the queued events during rAF. (Closed)
Patch Set: Fix nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/input/main_thread_event_queue.cc
diff --git a/content/renderer/input/main_thread_event_queue.cc b/content/renderer/input/main_thread_event_queue.cc
index c34e08a18da0a8fd20871f5faf8cf53f18834ae7..99881bdf0e1a805a1bb2c7cf84ecd989fe01fc33 100644
--- a/content/renderer/input/main_thread_event_queue.cc
+++ b/content/renderer/input/main_thread_event_queue.cc
@@ -12,12 +12,6 @@ namespace content {
namespace {
-// The maximum number of post-coalesced events processed per rAF task. 10 was
-// chosen because it really should never be hit yet prevents an infinite loop if
-// the compositor keeps delivering events faster than the main thread can
-// process them.
-const size_t kMaxEventsPerRafTask = 10;
-
const size_t kTenSeconds = 10 * 1000 * 1000;
bool isContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) {
@@ -230,21 +224,21 @@ void MainThreadEventQueue::DispatchRafAlignedInput() {
if (!handle_raf_aligned_input_)
return;
+ std::deque<std::unique_ptr<EventWithDispatchType>> events_to_process;
{
base::AutoLock lock(shared_state_lock_);
shared_state_.sent_main_frame_request_ = false;
- }
-
- for (size_t i = 0; i < kMaxEventsPerRafTask; ++i) {
- {
- base::AutoLock lock(shared_state_lock_);
- if (shared_state_.events_.empty())
- break;
+ while(!shared_state_.events_.empty()) {
if (!isContinuousEvent(shared_state_.events_.front()))
break;
- in_flight_event_ = shared_state_.events_.Pop();
+ events_to_process.emplace_back(shared_state_.events_.Pop());
}
+ }
+
+ while(!events_to_process.empty()) {
+ in_flight_event_ = std::move(events_to_process.front());
+ events_to_process.pop_front();
DispatchInFlightEvent();
}
PossiblyScheduleMainFrame();
« no previous file with comments | « no previous file | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698