Trace OpenGL calls on Android

633 views
Skip to first unread message

stasgu

unread,
Jul 19, 2010, 9:35:27 AM7/19/10
to android-platform
Hi,

I want to be able to trace gl calls on Android. Something like
glTrace, which basically intercepts and logs opengl calls, on any
application, transparent to the application (no code changed). I've
googled around, and haven't find anything.
So I tried another approach, generated a <app>.trace file in the
eclipse IDE (used for traceview) , to get a trace of all function
calls and extracted gles_jni calls from there. That is great, the
problem is that it works only on applications that I have source for,
and not on any application. So suggestions on any of those options is
very welcomed:

1. Is there a way to generate trace files for any android java
application, without using eclipse and having the source code?
2. I've tried to look at the jni implementation of the gl functions,
and the files have this line:
// This source file is automatically generated
for example:
./frameworks/base/core/jni/android_opengl_GLES10.cpp
For this option I'll need to know how this files are generated and add
some code to add tracing calls in every gl function.
3. The best option is obviously if there's a tool that can trace gl
calls.

If there's another option I've missed, please suggest.

Thanks.

stasgu

unread,
Jul 21, 2010, 8:15:42 AM7/21/10
to android-platform
So I wrote a script that adds trace log to all jni GL files:

* android_opengl_GLES10.cpp
* android_opengl_GLES10Ext.cpp
* android_opengl_GLES11.cpp
* android_opengl_GLES11Ext.cpp
* com_google_android_gles_jni_EGLImpl.cpp
* com_google_android_gles_jni_GLImpl.cpp

It works fine, and I get a log of all gl and egl calls that go thought
those jni calls.
The problem is that some applications are "getting smart" (I think
google earth is like that, and I know that the gl2jni test is like
that) so they define their own jni call that calls the native gl
functions.
For example:
They define a jni function called draw_frame, and call it from the
java activity. This draw_frame calls the native gl functions.

This method, used probably for performance, obsoletes the jni trace of
all gl methods.
So I guess the next thing is to actually write a gltrace like library,
that will replace the libGL.so with the tracing one.

stasgu

unread,
Jul 29, 2010, 4:38:39 AM7/29/10
to android-platform
The source for libGLESv1_CM.so is under frameworks/base/opengl/libs/
GLES_CM. The gl.cpp is the one implements the linking to the driver.
All methods are located in gl_api.in file, which is included in
gl.cpp. If you want to add tracing code, that's the place to put it,
before the calls to the driver functions.

On Jul 21, 3:15 pm, stasgu <sta...@gmail.com> wrote:
> So I wrote a script that addstracelog to all jni GL files:
>
>     * android_opengl_GLES10.cpp
>     * android_opengl_GLES10Ext.cpp
>     * android_opengl_GLES11.cpp
>     * android_opengl_GLES11Ext.cpp
>     * com_google_android_gles_jni_EGLImpl.cpp
>     * com_google_android_gles_jni_GLImpl.cpp
>
> It works fine, and I get a log of all gl and egl calls that go thought
> those jni calls.
> The problem is that some applications are "getting smart" (I think
> google earth is like that, and I know that the gl2jni test is like
> that) so they define their own jni call that calls the native gl
> functions.
> For example:
> They define a jni function called draw_frame, and call it from the
> java activity. This draw_frame calls the native gl functions.
>
> This method, used probably for performance, obsoletes the jnitraceof
> all gl methods.
> So I guess the next thing is to actually write a gltrace like library,
> that will replace the libGL.so with the tracing one.
>
> On Jul 19, 4:35 pm, stasgu <sta...@gmail.com> wrote:
>
> > Hi,
>
> > I want to be able totracegl calls on Android. Something like
> > glTrace, which basically intercepts and logsopenglcalls, on any
> > application, transparent to the application (no code changed). I've
> > googled around, and haven't find anything.
> > So I tried another approach, generated a <app>.tracefile in the
> > eclipse IDE (used for traceview) , to get atraceof all function
> > calls and extracted gles_jni calls from there. That is great, the
> > problem is that it works only on applications that I have source for,
> > and not on any application. So suggestions on any of those options is
> > very welcomed:
>
> > 1. Is there a way to generatetracefiles for any android java
Reply all
Reply to author
Forward
0 new messages