Changes

Jump to: navigation, search

B2G/Debugging OpenGL

2,163 bytes added, 00:04, 8 June 2012
Created page with "This page describes how to use the apitrace tool to debug OpenGL calls when using Boot2Gecko. Special thanks goes out to gw280 who wrote the following: http://www.hackermusings...."
This page describes how to use the apitrace tool to debug OpenGL calls when using Boot2Gecko.

Special thanks goes out to gw280 who wrote the following: http://www.hackermusings.com/2012/03/debugging-opengl-on-android-without-losing-your-sanity/ which is what most of this is based on.

===Get a copy of apitrace===

The first thing to do is to grab a copy of apitrace.
<pre>
git clone https://github.com/apitrace/apitrace.git
</pre>

The INSTALL.markdown file contains instructions for building. I'll summarize what I did:

===Install the Android NDK===
<pre>
cd /home/work
wget http://dl.google.com/android/ndk/android-ndk-r8-linux-x86.tar.bz2
tar xf android-ndk-r8-linux-x86.tar.bz2
</pre>

===Install cmake and needed Qt packages===
<pre>
sudo apt-get install cmake libqjson-dev libqtwebkit-dev
</pre>

===Build for the host (linux)===
<pre>
cmake -H. -Bbuild
make -C build
</pre>

===Build for the phone===
<pre>
export ANDROID_NDK=/home/work/android-ndk-r8
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake -DANDROID_API_LEVEL=9 -H. -Bbuild-b2g
make -C build-b2g
</pre>

The egltrace.so for the ARM will be found in <tt>libs/armeabi-v7a/egltrace.so</tt>

===Install egltrace.so onto the phone===
<pre>
adb push libs/armeabi-v7a/egltrace.so /data
</pre>

===Run b2g===
I used the following run-apitrace.sh script, which places the trace in /data/egl.trace. If you don't specify <tt>TRACE_FILE</tt> then it wioll be called <tt>firefox.trace</tt> and will be placed in the same directory as the executable, so <tt>/system/b2g/firefox.trace</tt>
<pre>
#!/bin/bash
#set -x

. load-config.sh

ADB=adb
B2G_BIN=/system/b2g/b2g

B2G_PID=`$ADB shell toolbox ps |
grep "b2g" | awk '{ print \$2; }'`

$ADB shell kill $B2G_PID
$ADB shell stop b2g
$ADB shell TRACE_FILE=/data/egl.trace LD_PRELOAD=/data/egltrace.so LD_LIBRARY_PATH=/system/b2g ${B2G_BIN}
</pre>

===Analyze the captured trace===
<pre>
export EGL_SOFTWARE=true
qapitrace
</pre>

If you choose Trace->Replay then you should see the capture replay the captured trace, and it will then show a thumbnail next to each frame.

Before running Trace->Replay

After running Trace->Replay
Confirm
69
edits

Navigation menu