diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-01 22:01:53 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-01 22:01:53 +0000 |
commit | b105b9e664ff54e87fa16c5db5bf9050113eed91 (patch) | |
tree | a0242fd0a67e3a04d899ff99b60a932d9a25f713 /base/message_pump_glib.h | |
parent | 69a4b1aad922997400258ad7e403441ee1ea448b (diff) | |
download | chromium_src-b105b9e664ff54e87fa16c5db5bf9050113eed91.zip chromium_src-b105b9e664ff54e87fa16c5db5bf9050113eed91.tar.gz chromium_src-b105b9e664ff54e87fa16c5db5bf9050113eed91.tar.bz2 |
linux: fix main loop issues with windowless plugins
In certain conditions (e.g. NPN_InvalidateRect taking long), the flash plugin runs its own event loop before returning. It looks roughly like this:
while (gtk_events_pending()) {
gtk_main_iteration();
}
The problem is that our worker source used to force gtk_events_pending() to be always true, because the Check handler always returned TRUE (and that also made HandleDispatch to always run). That caused flash animations to stop and other bad behavior (100% CPU).
This CL changes the Check function to return TRUE only if HandleDispatch should be run (i.e., more_work_is_plausible set to true), while also checking whether the loop was woken up, or the delayed work timer expired.
HandlePrepare was forcing more_work_is_plausible to be always true apparently to avoid starvation. I removed this, I'm not sure why it is needed. If we get starvation issue, we should raise the priority of WorkSource (for reference, most events run at prio 0, except redraws that run at prio 120. WorkSource runs at prio 200). Another possibility is to force more_work_is_plausible but only every n calls to HandlePrepare.
BUG=8202,11843,12278
Review URL: http://codereview.chromium.org/115812
Patch from Antoine Labour <piman@google.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib.h')
-rw-r--r-- | base/message_pump_glib.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h index 4fafaaf..e8288a8 100644 --- a/base/message_pump_glib.h +++ b/base/message_pump_glib.h @@ -42,9 +42,11 @@ class MessagePumpForUI : public MessagePump { // Internal methods used for processing the pump callbacks. They are // public for simplicity but should not be used directly. HandlePrepare // is called during the prepare step of glib, and returns a timeout that - // will be passed to the poll. HandleDispatch is called after the poll - // has completed. + // will be passed to the poll. HandleCheck is called after the poll + // has completed, and returns whether or not HandleDispatch should be called. + // HandleDispatch is called if HandleCheck returned true. int HandlePrepare(); + bool HandleCheck(); void HandleDispatch(); // Add an Observer, which will start receiving notifications immediately. @@ -66,9 +68,10 @@ class MessagePumpForUI : public MessagePump { // Used to count how many Run() invocations are on the stack. int run_depth; - // Used internally for controlling whether we want a message pump - // iteration to be blocking or not. - bool more_work_is_plausible; + // This keeps the state of whether the pump got signaled that there was new + // work to be done. Since we eat the message on the wake up pipe as soon as + // we get it, we keep that state here to stay consistent. + bool has_work; }; // Invoked from EventDispatcher. Notifies all observers we're about to |