Register now for Android Dev Summit 2019!

Analyze OpenGL with Tracer

Tracer is deprecated. Beginning with Android Studio 3.1, you should instead use the Graphics API Debugger to inspect and debug calls from an app to a graphics driver.

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:

  1. Start Android Device Monitor.
  2. In the Android Device Monitor, activate the perspective for Tracer by selecting Window > Open Perspective from the menu bar.
  3. Select Tracer for OpenGL ES and click OK.
  4. 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.
  5. Click the trace capture button from the toolbar. This opens the OpenGL ES Trace Options dialog.
  6. 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.
  7. Click Trace to start the trace capture.
  8. Interact with your app while the tool captures tracing information.
  9. 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.