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.
(These instructions have been carefully distilled from http://code.google.com/p/chromium/wiki/AndroidBuildInstructions)
target_os = ['android']
chromium.gyp_env
next to your .gclient file: echo "{ 'GYP_DEFINES': 'OS=android', }" > chromium.gyp_env
gclient sync --nohooks . build/android/envsetup.sh gclient runhooks
chmod +x
, and then execute to extract. You then move that extracted tree into /usr/lib/jvm/, rename it java-6-sun and set:export JAVA_HOME=/usr/lib/jvm/java-6-sun export ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-sun
java -version
’ and make sure it says java version "1.6.0_35” without any mention of openjdk before proceeding.sudo build/install-build-deps-android.sh
ninja -C out/Release content_shell_apk
Plug in your device. Make sure you can talk to your device, try “
adb shell ls
”
adb root
. Every time you connect your device you’ll want to run this.. build/android/envsetup.sh
”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/
You can run any Telemetry benchmark with --profiler=perf, and it will:
You can also run “manual” tests with Telemetry, more information here: http://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.
# 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)
Rebuild content_shell_apk with profiling enabled
export GYP_DEFINES="$GYP_DEFINES profiling=1" build/gyp_chromium ninja -C out/Release content_shell_apk
Install with the following:
build/android/adb_install_apk.py --apk out/Release/apks/ContentShell.apk --apk_package org.chromium.content_shell
Run with the following:
./build/android/adb_run_content_shell
If content_shell “stopped unexpectedly” use “
adb logcat
” to debug. If you see ResourceExtractor exceptions, a clean build is your solution. crbug.com/164220
adb logcat | grep libcontent_shell_content_view.so
You should find a path that’s something like /data/app-lib/org.chromium.content_shell-1/libcontent_shell_content_view.so
mkdir symbols (this guide assumes you put this next to src/)
mkdir -p symbols/data/app-lib/org.chromium.content_shell-1 (or whatever path in app-lib you got above) 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.
chmod a+x perfhost_linux
Run the following:
adb shell ps | grep content (look for the pid of the sandboxed_process) adb shell perf record -g -p 12345 sleep 5 adb pull /data/perf.data
./perfhost_linux report -g -i perf.data --symfs symbols/
adb shell echo “0” > /proc/sys/kernel/kptr_restrict
adb pull /proc/kallsyms symbols/kallsyms
./perfhost_linux report -g -i perf.data --symfs symbols/ --kallsyms=symbols/kallsyms