Tracer is a tool for analyzing your app's OpenGL for Embedded Systems (ES) code. The tool allows you to capture OpenGL ES commands and frame by frame images to help you understand how Android is executing your graphics commands.
Tracer captures OpenGL ES command execution logs and can also capture progressive images of the
frames generated by those commands. The tool saves this information to a .gltrace file
that you can use to perform logical and visual analysis of your OpenGL ES code.
To capture an OpenGL ES trace, proceed as follows:
- From Android Studio, start Android Device Monitor by selecting Tools > Android > Android Device Monitor from the menu bar.
- In the Android Device Monitor, activate the perspective for Tracer by selecting Window > Open Perspective from the menu bar.
- Select Tracer for OpenGL ES and click OK.
- Connect a device running Android 4.1 (API Level 16) or higher. If you're using a physical device, make sure it's enabled for debugging.
- Click the trace capture button
from the
toolbar. This opens the OpenGL ES Trace Options dialog, as shown in figure 1.
Figure 1. OpenGL ES Trace Options dialog box.
- Configure your trace as follows:
- Select your device from the Device dropdown menu.
- In the Application Package field, enter the full app package name containing the activity you want to trace.
- In the Activity to launch field, enter the class name of the activity you want to trace. If you are tracing the default activity for your app, you can leave this field blank.
- Enable the Data Collection Options you want by checking the appropriate checkboxes. If you want to capture progressive frame images for each drawing call, select the Read back currently bound framebuffer on glDraw*() checkbox. Be aware that using this option can result in large trace files.
- Enter a path and filename for the trace output in the field next to Destination File.
- Click Trace to start the trace capture.
- Interact with your app while the tool captures tracing information.
- In the dialog box, click Stop Tracing to end the tracing session.
After you have generated a trace, you can load it for review and analysis by clicking Open
Trace File
. After that, select a
frame and review the OpenGL ES calls. Drawing commands are highlighted in blue.