From a3919cb0ec14a09b5b2aff58efbbddf961879efb Mon Sep 17 00:00:00 2001 From: Masako Toda Date: Tue, 21 Jul 2020 16:26:41 +0000 Subject: [PATCH] Fix excessive CPU usage with external and multi-threaded message loops (fixes issue #2809, fixes issue #2970). --- libcef/browser/browser_message_loop.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libcef/browser/browser_message_loop.cc b/libcef/browser/browser_message_loop.cc index b5b3db724..9e632c694 100644 --- a/libcef/browser/browser_message_loop.cc +++ b/libcef/browser/browser_message_loop.cc @@ -70,19 +70,21 @@ class MessagePumpExternal : public base::MessagePumpForUI { // is_immediate() returns true if the next task is ready right away. more_immediate_work = next_work_info.is_immediate(); if (!more_immediate_work) { - // DoIdleWork() returns true if idle work was all done. - more_idle_work = !delegate->DoIdleWork(); - // Check the next PendingTask's |delayed_run_time|. // is_max() returns true if there are no more immediate nor delayed tasks. more_delayed_work = !next_work_info.delayed_run_time.is_max(); - if (more_delayed_work && !more_idle_work) { + if (more_delayed_work) { // The only remaining work that we know about is the PendingTask. // Consider the run time for that task in the time slice calculation. *next_run_time = next_work_info.delayed_run_time; } } + if (!more_immediate_work && !more_delayed_work) { + // DoIdleWork() returns true if idle work was all done. + more_idle_work = !delegate->DoIdleWork(); + } + return more_immediate_work || more_idle_work || more_delayed_work; }