Last Comment Bug 633239 - event loop responsiveness for Android
: event loop responsiveness for Android
Product: Core
Classification: Components
Component: Widget: Android (show other bugs)
: Trunk
: ARM Android
-- normal (vote)
: mozilla10
Assigned To: Brad Lassey [:blassey] (use needinfo?)
: Jim Chen [:jchen] [:darchons]
Depends on: 606574
  Show dependency treegraph
Reported: 2011-02-10 09:46 PST by Ted Mielczarek [:ted.mielczarek]
Modified: 2011-10-29 01:48 PDT (History)
10 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

patch (3.67 KB, patch)
2011-04-13 12:00 PDT, Brad Lassey [:blassey] (use needinfo?)
ted: review+
doug.turner: review-
Details | Diff | Splinter Review
patch (5.44 KB, patch)
2011-08-04 00:35 PDT, Brad Lassey [:blassey] (use needinfo?)
doug.turner: review+
Details | Diff | Splinter Review
patch (5.68 KB, patch)
2011-10-24 15:35 PDT, Brad Lassey [:blassey] (use needinfo?)
ted: review-
Details | Diff | Splinter Review
patch (5.81 KB, patch)
2011-10-26 12:26 PDT, Brad Lassey [:blassey] (use needinfo?)
ted: review+
Details | Diff | Splinter Review

Description User image Ted Mielczarek [:ted.mielczarek] 2011-02-10 09:46:06 PST
Splitting this off from bug 606574 because a) we need this for Firefox first anyway, and b) I don't know the Android widget code well enough to quickly put together an implementation.
Comment 1 User image Ted Mielczarek [:ted.mielczarek] 2011-02-10 09:51:19 PST
The implementation consists of a C++ function, "bool FireAndWaitForTracerEvent()". It should submit an event to the native event queue and then block until the event is procesed. The GTK2 implementation is here, for example:
Comment 2 User image Brad Lassey [:blassey] (use needinfo?) 2011-04-13 12:00:21 PDT
Created attachment 525750 [details] [diff] [review]
Comment 3 User image Doug Turner (:dougt) 2011-04-13 22:47:04 PDT
i'd like to see this working before r+.  it looks like it should work.

fireAndWaitForTracerEvent is called on some thread.  We must ensure that it is never called on the main handler thread or we will deadlock.  Can we add assertion -- or a runtime abort if that happens?

Ted, how do we test this?  It looks pretty interesting!
Comment 4 User image Ted Mielczarek [:ted.mielczarek] 2011-04-14 04:52:31 PDT
FireAndWaitForTracerEvent is always called from a particular background thread. It's documented in the header that it must not be called from the UI thread:

 I think that's enough, although a main-thread check with a runtime abort would be a fine sanity check addition (although I didn't do this in any of the other widget implementations).

You can test this by running the browser with MOZ_INSTRUMENT_EVENT_LOOP=1 in the environment. On Android, you'll also want to set MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT to a path to a file to contain the output (it defaults to stdout). You should get at least a start and stop line in the file, and presumably some other lines if you interact with the UI and get some slowness. There's some slightly more useful documentation in the source:

Note that my patches in bug 606574 got backed out for leaking, so you'll have to either re-apply them or apply your patch on top of their original changesets to test. I should be able to get them re-landed today or tomorrow.
Comment 5 User image Ted Mielczarek [:ted.mielczarek] 2011-04-15 11:20:19 PDT
Comment on attachment 525750 [details] [diff] [review]

I need to update my patches on bug 606574, I'll come back to this when I'm done just in case I have to change the API at all. Should get back to this early next week.
Comment 6 User image Ted Mielczarek [:ted.mielczarek] 2011-04-21 06:11:15 PDT
Comment on attachment 525750 [details] [diff] [review]

Looks fine, but my revised patches added init and cleanup methods, so you'll need to put stubs of those in: bool InitWidgetTracing() and void CleanUpWidgetTracing() (both in namespace mozilla).
Comment 7 User image Doug Turner (:dougt) 2011-05-16 10:56:43 PDT
Comment on attachment 525750 [details] [diff] [review]

per ted, this needs more (the init and close methods).  Also, a sample output would be nice to see.
Comment 8 User image Brad Lassey [:blassey] (use needinfo?) 2011-08-04 00:35:11 PDT
Created attachment 550617 [details] [diff] [review]
Comment 9 User image Benoit Girard (:BenWa) 2011-09-02 09:20:51 PDT
I'm very interested in using this patch with the profiler I'm suggesting in bug 633239.
Comment 10 User image Doug Turner (:dougt) 2011-09-25 13:58:31 PDT
Comment on attachment 550617 [details] [diff] [review]

Review of attachment 550617 [details] [diff] [review]:

good to have the patch lying around, but I am not sure we should land any of this until there is some user needing this.  Ted - what is the status here?  Is this going to be part of some automated testing ?
Comment 11 User image Ted Mielczarek [:ted.mielczarek] 2011-09-26 07:14:02 PDT
Alice is spinning up Talos testing of this metric in bug 631571. Note that all the other platform backends landed months ago. I don't see any reason why Android shouldn't do the same.
Comment 12 User image Brad Lassey [:blassey] (use needinfo?) 2011-10-24 15:35:38 PDT
Created attachment 569207 [details] [diff] [review]
Comment 13 User image Ted Mielczarek [:ted.mielczarek] 2011-10-25 05:10:41 PDT
Comment on attachment 569207 [details] [diff] [review]

Review of attachment 569207 [details] [diff] [review]:

::: widget/src/android/AndroidBridge.cpp
@@ +1086,5 @@
> +   void SignalTracerThread()
> +   {
> +       MutexAutoLock lock(*mTracerLock);
> +       mHasRun = PR_TRUE;
> +       mTracerCondVar->Notify();

This...isn't a member function of TracerRunnable, so this won't work.
Comment 14 User image Brad Lassey [:blassey] (use needinfo?) 2011-10-26 12:26:02 PDT
Created attachment 569754 [details] [diff] [review]
Comment 15 User image Brad Lassey [:blassey] (use needinfo?) 2011-10-28 10:59:16 PDT
Comment 16 User image Marco Bonardo [::mak] 2011-10-29 01:48:34 PDT

Note You need to log in before you can comment on or make changes to this bug.