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

Issue 115812: linux: fix main loop issues with windowless plugins (Closed)

Created:
11 years, 7 months ago by Antoine Labour
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

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

Patch Set 1 #

Total comments: 6

Patch Set 2 : Make message loop follow more closely the Windows one #

Total comments: 12

Patch Set 3 : Fixing comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+99 lines, -43 lines) Patch
M base/message_pump_glib.h View 1 2 chunks +8 lines, -5 lines 0 comments Download
M base/message_pump_glib.cc View 1 2 4 chunks +91 lines, -38 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
Antoine Labour
11 years, 7 months ago (2009-05-27 05:19:03 UTC) #1
Evan Martin
Adding Darin because he's the messageloop ninja, and estade because something like this may fix ...
11 years, 7 months ago (2009-05-27 05:50:58 UTC) #2
Dean McNamee
I will think on this some more. If we have a good repro case (for ...
11 years, 7 months ago (2009-05-27 06:52:57 UTC) #3
Dean McNamee
This is probably more work than you wanted, but we need some tests. We need ...
11 years, 7 months ago (2009-05-27 07:01:58 UTC) #4
Dean McNamee
After a deeper look at the code, the previous changes, and the GTK/Glib sources, I ...
11 years, 7 months ago (2009-05-27 09:23:13 UTC) #5
Evan Stade
With this patch, the file picker trouble goes away (at least on the laptop I've ...
11 years, 7 months ago (2009-05-27 20:49:05 UTC) #6
Dean McNamee
This looks better. We still need some tests :( I am a bit confused, it ...
11 years, 6 months ago (2009-05-29 09:48:22 UTC) #7
Dean McNamee
btw, ignore my comment about has_work, I wrote it before reading the rest of the ...
11 years, 6 months ago (2009-05-29 09:49:30 UTC) #8
Dean McNamee
I should say that I think I like the simplification of moving a bunch of ...
11 years, 6 months ago (2009-05-29 09:51:42 UTC) #9
darin (slow to review)
Looks good to me, but I'm no expert on the glib runloop stuff. http://codereview.chromium.org/115812/diff/1005/1006 File ...
11 years, 6 months ago (2009-06-01 14:07:43 UTC) #10
Evan Martin
I'd like to make progress on this patch. I'm not sure if Dean's last comments ...
11 years, 6 months ago (2009-06-01 18:54:32 UTC) #11
Antoine Labour
http://codereview.chromium.org/115812/diff/1005/1006 File base/message_pump_glib.cc (right): http://codereview.chromium.org/115812/diff/1005/1006#newcode66 Line 66: // - return true iff any of prepare() ...
11 years, 6 months ago (2009-06-01 21:15:17 UTC) #12
Dean McNamee
11 years, 6 months ago (2009-06-02 09:06:47 UTC) #13
LGTM w/ the following conditions:

- You're on the hook for some more / better tests.
- When you write the tests, make sure they behave the same before and after this
patch.  It is easy to write tests for the "fixed" code that hide regressions.

On 2009/06/01 21:15:17, Antoine Labour wrote:
> http://codereview.chromium.org/115812/diff/1005/1006
> File base/message_pump_glib.cc (right):
> 
> http://codereview.chromium.org/115812/diff/1005/1006#newcode66
> Line 66: // - return true iff any of prepare() or check() returned true
> On 2009/05/29 09:48:22, Dean McNamee wrote:
> > if not iff (I realize it's not a typo, but we don't ever say "if and only
if"
> > when we just mean if).
> 
> Done.
> 
> http://codereview.chromium.org/115812/diff/1005/1006#newcode81
> Line 81: // event pumps
> On 2009/05/29 09:48:22, Dean McNamee wrote:
> > period / capitalization.
> 
> Done.
> 
> http://codereview.chromium.org/115812/diff/1005/1006#newcode83
> Line 83: // loop, around event handling.
> On 2009/05/29 09:48:22, Dean McNamee wrote:
> > capitalization
> 
> Done.
> 
> http://codereview.chromium.org/115812/diff/1005/1006#newcode200
> Line 200: 
> On 2009/06/01 14:07:43, darin wrote:
> > nit: might be nice to eliminate this newline here for consistency with the
> code
> > above.  might help readability a tad.
> 
> Done.
> 
> http://codereview.chromium.org/115812/diff/1005/1006#newcode257
> Line 257: // NOTE: on Windows at this point we would call ScheduleWork. But
> here,
> On 2009/06/01 14:07:43, darin wrote:
> > Windows does that in the corresponding code to support being called on a
> > background thread.  I'm guessing this function can never be called on a
> > background thread, then?
> 
> This function can only be called from the UI thread. has_work is only accessed
> from that thread.
> I added a reference to what I was talking about:
> MessagePumpForUI::HandleWorkMessage. I'm doubtful that it can be called from
> another thread though (since it calls DoWork, that would be a problem).

Powered by Google App Engine
This is Rietveld 408576698