Closed
Bug 1157638
Opened 10 years ago
Closed 10 years ago
Write a script to easily detect applications that keep running when the phone is in standby and/or not connected via ADB
Categories
(Firefox OS Graveyard :: Developer Tools, defect)
Firefox OS Graveyard
Developer Tools
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: gsvelto, Assigned: gsvelto)
Details
Attachments
(1 file)
The Flame has kernel tracing support fully enabled which allows us to easily track what applications are running even when the phone is not connected to a computer or even in standby mode. This would be useful to quickly diagnose battery-draining bugs that are often hard to debug as they happen when the phone is disconnected and in standby. Since kernel tracing is universally available this would also work on phones using user/production builds.
The script should enable tracing sched_stat_runtime events to know which applications have run and for how long and sched_wakeup events to know how many times the app woke up to run. The script should also process the trace when pulling it from the phone and create a readable summary out of it.
This is my contribution for April's hack-day, I've CC'ed everybody who was on the Etherpad + other people whom I think might be interested.
Comment 1•10 years ago
|
||
And now you would like to display this data in devtools?
In on-device devtools (Developer hud), or once you connect the device to a computer (webide)?
Note that WebIDE has a "Monitor" feature, that is extensible and can call some local commands to pull useful data about apps/OS.
You are talking about a "script" is that a shell script running some adb shell commands?
Comment 2•10 years ago
|
||
Thanks, that sounds very interesting. Is it possible to include wake-lock statistics into the output?
| Assignee | ||
Comment 3•10 years ago
|
||
Assignee: nobody → gsvelto
Status: NEW → ASSIGNED
| Assignee | ||
Comment 4•10 years ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #1)
> And now you would like to display this data in devtools?
For now I settled for a simple shell script but integrating this into devtools would be mighty cool.
> Note that WebIDE has a "Monitor" feature, that is extensible and can call
> some local commands to pull useful data about apps/OS.
I think that would make using this data directly into WebIDE very easy.
> You are talking about a "script" is that a shell script running some adb
> shell commands?
Yes. Try the attached script:
$ trace.sh --start
(do stuff even with your phone disconnected)
$ trace.sh --stop
NAME PID WAKEUPS RUNTIME NEW
b2g 751 0 3957 ms no
(Nuwa) 764 0 2 ms no
Homescreen 1180 0 714 ms no
Built-in Keyboa 1193 0 17 ms no
Usage 1568 0 10 ms no
Settings 1575 0 24 ms no
Smart Collectio 1853 0 2 ms no
Communications 1873 0 2316 ms no
Find My Device 7976 0 26 ms no
Camera 8424 0 7 ms no
Messages 9016 0 8 ms no
E-Mail 14409 0 2821 ms no
The script is still incomplete as it's a WIP so the WAKEUPS (how many times the app woke up) and NEW (was the app launched during tracing?) are not populated yet. Being a shell script it's also dog slow.
Comment 5•10 years ago
|
||
See this page on how to integrate with the Monitor:
https://developer.mozilla.org/en-US/docs/Tools/WebIDE/Monitor
For local commands it relies on connecting to a WebSocket server serving some JSON objects with the data.
I think there is some existing python command that does the websocket+adb thing somewhere if you are interested in this approach.
Doesn't sounds very easy from a bash script. But also see direct JS/C++ integration from code running directly within gecko.
| Assignee | ||
Comment 6•10 years ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #5)
> See this page on how to integrate with the Monitor:
> https://developer.mozilla.org/en-US/docs/Tools/WebIDE/Monitor
> For local commands it relies on connecting to a WebSocket server serving
> some JSON objects with the data.
> I think there is some existing python command that does the websocket+adb
> thing somewhere if you are interested in this approach.
> Doesn't sounds very easy from a bash script. But also see direct JS/C++
> integration from code running directly within gecko.
Python will be fine for that, thanks for the pointer. I wrote a shell script so that we would be able to quickly use it immediately before I turn it into something more polished.
| Assignee | ||
Comment 7•10 years ago
|
||
I've pushed an updated script which properly traces wakeups and process creation, this is the output of me launching "Saga of Craigen - Ambush at the Dragon Pass" (arguably the best game ever made for Firefox OS):
NAME PID WAKEUPS RUNTIME NEW
b2g 751 580 1300 ms no
(Nuwa) 764 0 0 ms no
Homescreen 1180 76 273 ms no
Built-in Keyboa 1193 0 0 ms no
Usage 1568 27 19 ms no
Settings 1575 30 127 ms no
Smart Collectio 1853 35 20 ms no
Communications 1873 48 467 ms no
Find My Device 7976 11 15 ms no
Camera 8424 2 16 ms no
Messages 9016 47 211 ms no
E-Mail 14409 23 42 ms no
Gallery 16302 29 99 ms no
Calendar 16331 9 62 ms no
Craigen 16957 256 5733 ms yes
| Assignee | ||
Comment 8•10 years ago
|
||
Comment on attachment 8596553 [details] [review]
[PULL REQUEST] Add a script to easily trace applications
We don't really have an owner for this so r? Dave who's reviewed most changes to similar tools (such as b2g-info) and possesses impressive shell-fu skills.
Attachment #8596553 -
Flags: review?(dhylands)
Comment 9•10 years ago
|
||
Comment on attachment 8596553 [details] [review]
[PULL REQUEST] Add a script to easily trace applications
Looks good - I made a few comments - all pretty minor, except for the hard-coded paths.
Attachment #8596553 -
Flags: review?(dhylands) → review+
| Assignee | ||
Comment 10•10 years ago
|
||
Thanks for the review! I've addressed the review comments - especially the hard-coded paths - and merged to b2g/master 57b7ad53740712d9390d4eb8ea0db45408c3a0b1
https://github.com/mozilla-b2g/B2G/commit/57b7ad53740712d9390d4eb8ea0db45408c3a0b1
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•