Below are the instructions for setting up profiling for Content Shell on Android. This will let you generate profiles for ContentShell. This will require linux, building an userdebug Android build, and wiping the device.
You need an Android 4.2+ device (Galaxy Nexus, Nexus 4, 7, 10, etc.) which you don’t mind erasing all data, rooting, and installing a userdebug build on.
More detailed insturctions in android_build_instructions.md.
ninja -C out/Release content_shell_apk
Plug in your device. Make sure you can talk to your device, try:
third_party/android_sdk/public/platform-tools/adb shell ls
manta / android-4.2.2_r1or
master / full_manta-userdebug.
adb root. Every time you connect your device you’ll want to run this.
If you get the error
error: device offline, you may need to become a developer on your device before Linux will see it. On Jellybean 4.2.1 and above this requires going to “about phone” or “about tablet” and clicking the build number 7 times: http://androidmuscle.com/how-to-enable-usb-debugging-developer-options-on-nexus-4-and-android-4-2-devices/
content_shell_apk with profiling enabled.
gn args out/Profiling # add "enable_profiling = true" ninja -C out/Profiling content_shell_apk export CHROMIUM_OUTPUT_DIR="$PWD/out/Profiling"
You can run any Telemetry benchmark with
--profiler=perf, and it will:
You can also run “manual” tests with Telemetry, more information here: https://www.chromium.org/developers/telemetry/profiling#TOC-Manual-Profiling---Android
The following steps describe building
perf, which is no longer necessary if you use Telemetry.
Even if you're not running a Telemetry test, you can use Catapult to automatically push binaries and pull the profile data for you.
build/android/adb_profile_chrome --browser=content_shell --perf
While you still have to build, install and launch the APK yourself, Catapult will take care of creating the symfs etc. (i.e. you can skip the “not needed for Telemetry” steps below).
# From inside the Android source tree (not inside Chromium) mmm external/linux-tools-perf/ adb remount # (allows you to write to the system image) adb sync adb shell perf top # check that perf can get samples (don’t expect symbols)
Install with the following:
content_shell “stopped unexpectedly” use
adb logcat to debug.
Figure out exactly what path
content_shell_apk (or chrome, etc) installs to.
adb logcat | grep libcontent_shell_content_view.so
You should find a path that’s something like
Make a symbols directory
mkdir symbols (this guide assumes you put this next to src/)
Make a symlink from your symbols directory to your un-stripped
# Use whatever path in app-lib you got above mkdir -p symbols/data/app-lib/org.chromium.content_shell-1 ln -s `pwd`/src/out/Release/lib/libcontent_shell_content_view.so \ `pwd`/symbols/data/app-lib/org.chromium.content_shell-1
Note: modern versions of perf may also be able to process the perf.data files from the device.
perfhost_linux can be built from: https://android.googlesource.com/platform/external/linux-tools-perf/.
perfhost_linux next to symbols, src, etc.
chmod a+x perfhost_linux
Run the following:
out/Release/content_shell_apk ps (look for the pid of the sandboxed_process) adb shell perf record -g -p 12345 sleep 5 adb pull /data/perf.data
Run the following:
./perfhost_linux report -g -i perf.data --symfs symbols/
If you don’t see chromium/webkit symbols, make sure that you built/pushed Release, and that the symlink you created to the .so is valid!
By default, /proc/kallsyms returns 0 for all symbols, to fix this, set
adb shell echo “0” > /proc/sys/kernel/kptr_restrict
See http://lwn.net/Articles/420403/ for explanation of what this does.
adb pull /proc/kallsyms symbols/kallsyms
Now add --kallsyms to your perfhost_linux command:
./perfhost_linux report -g -i perf.data --symfs symbols/ \ --kallsyms=symbols/kallsyms