Provide a script which captures a startup profile from Fenix over adb
Categories
(Core :: Gecko Profiler, enhancement, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: mstange, Assigned: mleclair, NeedInfo)
References
Details
(Whiteboard: [fxdroid],[group1])
Attachments
(1 file)
It's too much work to get a startup profile from Firefox for Android using the Gecko profiler.
It would be great to have a script which does the following, using adb:
- Terminate any running Firefox processes.
- Launch Firefox in a way that simulates either a tap on the icon or an app link intent.
- Wait for a number of seconds, defaulting to 10 seconds but configurable with a command line argument.
- Send a signal to the Fenix parent process to save the profile to disk (bug 1904639).
- Wait for the profile to be collected.
- Pull the profile JSON file from the phone.
- If samply is installed, run
samply load profile.json
We have an existing setup-startup-profiling.py script which we could morph into a startup-profiling.py script with a new record subcommand.
Then all of this could just become a single command: ./mobile/android/fenix/tools/startup-profiling.py record nightly
For comparison, here's what you have to do to get startup profiles from Firefox for Android today:
- Go to the Firefox settings and turn off Remote Debugging, in order to avoid startup overhead from it.
- Execute adb commands on the host to terminate running Firefox processes and send the intent to launch Firefox.
- Wait until startup finishes.
- Using your finger on the phone screen, go into the Firefox settings and re-enable Remote Debugging.
- On the host machine, go back to the
about:debuggingtab, click connect, click the phone, click Profile performance, click Capture recording, wait. (that's 5 clicks, see bug 1884893)
Comment 1•1 year ago
•
|
||
Would having something like the new button in about:profiling to restart fenix with profiling work?
I'm also working on adding code to about:logging to be able to upload and share a profile URL easily from Android (bug 1803607). So maybe gluing both works would solve this issue?
| Reporter | ||
Comment 2•1 year ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #1)
Would having something like the new button in about:profiling to restart fenix with profiling work?
Sure, but wouldn't that be quite a bit harder to implement? And I feel like the bar for quality is quite a bit higher in functionality that is exposed through the browser UI, as opposed to something that's just in a developer script.
For example:
- Startup profiling needs to happen with remote debugging off. How would you get to the about:profiling UI for the phone? Not via about:debugging? Or would you load about:profiling into the Android browser?
- Setting the startup environment variables for startup profiling can currently only be done via a yaml file which is stored in a place that's only readable but not writable by the app. How would about:profiling create the file? By using adb on the host, I guess?
- With the current script, you need to invoke
deactivateexplicitly to turn startup profiling back off. It's easy to forget this. If we exposed something on about:profiling it would need to automatically turn the environment variables off for the next restart, I guess also using adb directly.
I'm also working on adding code to about:logging to be able to upload and share a profile URL easily from Android (bug 1803607). So maybe gluing both works would solve this issue?
Maybe? Seems rather non-specific at the moment. The script approach we know how to do (with the one exception that we haven't verified whether sending a signal with adb works).
| Reporter | ||
Comment 3•11 months ago
|
||
(In reply to Markus Stange [:mstange] from comment #0)
- Terminate any running Firefox processes.
- Launch Firefox in a way that simulates either a tap on the icon or an app link intent.
- Wait for a number of seconds, defaulting to 10 seconds but configurable with a command line argument.
- Send a signal to the Fenix parent process to save the profile to disk (bug 1904639).
I just tested this and it doesn't actually work - you can only send a signal if you're root, or if the target process is running under the same user. On Android there's one user per app. So Firefox can send a signal to itself but not to processes from other apps. And the adb shell user can't send a signal to Firefox. For a debuggable APK you can use run-as but we need a solution that works with non-debuggable apps.
I wonder how else we can trigger profile collection from a script. Maybe we can add an intent for this?
Updated•9 months ago
|
| Assignee | ||
Comment 4•8 months ago
|
||
Updated•7 months ago
|
Updated•6 months ago
|
Updated•4 months ago
|
Comment 7•4 months ago
|
||
Backed out for causing test apk fenix failure on ProfilerServiceTest.kt
Comment 9•3 months ago
|
||
| bugherder | ||
Description
•