When diagnosing performance problems it can be valuable to see what Chrome is doing "under the hood." One way to get a more detailed view into what's going on is to use the about:tracing tool.
You can even record tracing runs from Chrome on Android, though it's a bit more involved. You'll need your device running Chrome on Android with USB debugging enabled and attached to your computer. You'll also need ADB
. With these prerequisites in place, you can choose from the following two methods to record traces:
Or issue the following ADB command from your computer's shell:
$ adb shell am broadcast -a com.android.chrome.GPU_PROFILER_START -e file /sdcard/Download/trace.txt
(Note: 'com.android.chrome' is the package name for Chrome Stable. See below Note for Chrome Beta and other versions if you are tracing Chrome Beta or other versions)
Now do whatever is slow or incorrect in the browser on the device, then issue:
$ adb shell am broadcast -a com.android.chrome.GPU_PROFILER_STOP
(Also note the package name)
The results of the tracing run will be stored in /sdcard/Download. You can pull the file off of device and onto your computer with:
$ adb pull /sdcard/Download/trace.txt /path/on/your/computer/trace.txt
And access the trace file locally at /path/on/your/computer/trace.txt
Note for Chrome Beta and other versions: For the above commands to work you'll need to change the package name to whatever is appropriate for the APK. For instance, for Chrome for Android Beta change "com.android.chrome.GPU_PROFILER_START" to "com.chrome.beta.GPU_PROFILER_START" and so on (i.e. sub com.chrome.beta for com.android.chrome everywhere). For ContentShell, the commands are "org.chromium.content_shell.action.PROFILE_START" and "org.chromium.content_shell.action.PROFILE_START".
You can also use Android systrace to get trace if you are using Android JellyBean.
Pros: 1. It can show other Android system traces (e.g. surfaceflinger though some require root) along with Chrome traces; 2. It generates a self-contained html file.
Cons: It lacks some Chrome trace features, e.g. asynchronous events.