Closed Bug 1157908 Opened 8 years ago Closed 8 years ago

Lower the priority of Gecko thread Looper messages

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(firefox40 fixed)

RESOLVED FIXED
Firefox 40
Tracking Status
firefox40 --- fixed

People

(Reporter: jchen, Assigned: jchen)

Details

Attachments

(2 files, 1 obsolete file)

Right now, for every loop of the main Gecko thread event loop, we pump the Looper message loop once. This effectively gives Looper messages the same priority as Gecko events. Considering we only need to process Looper messages in rare cases, I think we are pumping the message loop unnecessarily. Moving the PumpMessageLoop call to nsAppShell::ProcessNextNativeEvent would reduce unnecessary calls.
Call pumpMessageLoop only when we don't have other events, rather than with every iteration of the event loop. I don't think it will have that big of an effect, but it's nice to have.
Attachment #8596834 - Flags: review?(snorp)
I also took some time to optimize pumpMessageLoop a bit. Before, C++ was calling pumpMessageLoop in Java through JNI, but pumpMessageLoop has to go back and call getNextMessageFromQueue in C++ through JNI again. This patch makes us cache the necessary Java references in AndroidBridge, so that we only have to cross the JNI boundary once.
Attachment #8596837 - Flags: review?(snorp)
Comment on attachment 8596834 [details] [diff] [review]
Give Gecko thread Looper low priority (v1)

Review of attachment 8596834 [details] [diff] [review]:
-----------------------------------------------------------------

I think Flash was (is) the only thing that ever used the Looper on the Gecko thread, but this seems fine.
Attachment #8596834 - Flags: review?(snorp) → review+
Attachment #8596837 - Flags: review?(snorp) → review+
Backed out for various Android test failures.
https://hg.mozilla.org/integration/mozilla-inbound/rev/6d0fb655e2e6

https://treeherder.mozilla.org/logviewer.html#?job_id=9281105&repo=mozilla-inbound was permafailing since this landed. There were failures in other chunks that looked related as well.
Various IPC crashes on debug builds too. Basically, make sure it's very green on Try before attempting to land again :)
Added AndroidBridge null-check.
Attachment #8596837 - Attachment is obsolete: true
Attachment #8598350 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/cad4ead8fc88
https://hg.mozilla.org/mozilla-central/rev/a2619dca0a16
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 40
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.