Download and install AGI for your operating system.
Android app requirements
This section describes the requirements for the Android app that is being
profiled:
Your Android app must be debuggable; the
debuggable attribute
in the Android manifest of the app must be set to true. This attribute
enables proper instrumentations from the graphics driver. For Vulkan
applications, this attribute enables AGI to add its own Vulkan layer when the
application starts.
<application[...]android:debuggable="true">
If your app uses Vulkan natively, AGI also requires the following:
Your app must have Vulkan validation layers
enabled. If they aren't enabled, you can run the following commands to force
your app to run with the validation layers that are included in the AGI apk
(com.google.android.gapid.<abi>):
app_package=<YOURAPPPACKAGENAMEHERE>
abi=arm64v8a# Possible values: arm64v8a, armeabi-v7a, x86
adbshellsettingsputglobalenable_gpu_debug_layers1
adbshellsettingsputglobalgpu_debug_app${app_package}
adbshellsettingsputglobalgpu_debug_layer_appcom.google.android.gapid.${abi}
adbshellsettingsputglobalgpu_debug_layersVK_LAYER_KHRONOS_validation
When you're done profiling can disable these validation layers with the
following commands:
Your app must not report any warnings or errors when it runs with the
Vulkan validation layers
enabled. Fix any Vulkan validation error before profiling.
If you are using beta GPU drivers, include the following metadata in the
<application> tag of the Android manifest:
adb debugging must be enabled and the device must be accessible through adb.
If the Install via USB option is present, enable it.
Device validation
AGI requires a compatible GPU driver. To ensure it provides valid profiling
data, AGI runs a validation check the first time you connect a new device, which
takes about ten seconds. After passing the check, you can use the device to
profile Android apps.
Do not disturb the device while validation is in progress. This may cause the
device to fail validation. If a device fails validation but is set up correctly,
you can retry validation by re-selecting the device.
Validation is a one-time step for a device, and results are cached for future
use of AGI. However, AGI will run validation again if the device setup changes,
such as if the GPU driver or Android version is updated.
If a device is listed as a supported device, you can
expect AGI to pass validation. If the device is not listed, its GPU driver is
most likely incompatible with AGI.
If your device is supported but fails validation
Make sure you've met all Android requirements and
computer requirements described in the preceding sections, and
that the device is properly connected to the computer with a USB cable.
If all of the requirements are met,
file a issue in our GitHub
repository describing the behavior.
If your device isn't supported
We are working with our OEM partners to add support for more devices. You can
file an issue in our
GitHub repository to request support for a device.
Capture profiling data
The following sections describe how to capture profiling data, and open the
resulting trace file so you can analyze the results.
Configure Android settings
Before you begin profiling, you must configure these Android app and device
settings, which specify the app and device to profile.
Using a USB cable, connect your Android device to your computer.
Launch AGI on your computer.
The first time you launch AGI, it displays the Welcome screen, which
prompts you for the path to the adb executable. AGI saves these settings in
the .agic file in your HOME folder. If you've already done this, you
can skip this step.
Welcome screen
Figure 1: Welcome screen.
Enter the path to the adb executable in the Path to adb field. The
checkboxes following this field are optional.
In the launch screen, click Capture a new trace. This displays
the Capture A New Trace dialog. Alternatively, you can click the
Capture System Profile trace button.
Capture A New Trace dialog
Figure 3: Capture A New Trace dialog.
In the Device and Type section, select the Android device you want to
profile. If it's not displayed in the Device list, click the reload
arrow to refresh the list.
In the Application section, select the app you want to profile. If
there is only one activity in the package, you can select the package
instead of the activity.
AGI includes a sample Vulkan app. To use the sample app instead of your own,
perform these steps:
Click the ... button next to the Application field.
This shows the Select an Application to Trace dialog, which
displays a list of apps that are traceable on the selected device.
In the Filter text box, type gapid to only display applications
that contain gapid in their package name.
Expand the package and select
com.google.android.gapid.VkSampleActivity, and then click OK.
This returns you to the Capture A New Trace dialog, with the
Application field populated by the app you selected.
In the Application section, leave the other fields empty.
Click OK.
Now you're ready to use AGI to perform system and frame profiling.
Profile a system
To profile a system, perform these steps:
In the AGI launch screen, click Capture a new trace to display the
Capture System Profile dialog.
In the Type list, select System profile.
In the Start and Duration section, set Start at to Manual,
and Duration to 2.
In the Trace Options section, click Configure. This displays a list
of profiling options.
Capture Config dialog
Figure 4: The profiling options in the
Capture System Profile dialog.
Select the profiling data you want to capture.
In the GPU section, click Select.
This displays a list of counters to select.
Counter config
Figure 5: Selecting counters.
Click default to select the set of default counters, and click OK
to return the profiling options.
Click OK to return to the main Capture System Profile dialog.
In the Output section, select an Output Directory to store the
the trace files that are generated during profiling. The File Name field
should be auto-filled, but you can also edit it.
Click OK. This starts the selected app on the Android device, and
displays a pop-up window with a Start button.
Click the Start button to start capturing profiling data, and wait a
couple of seconds for the process to finish.
Click Open Trace. The initial view that is displayed is
similar to systrace.
System profile trace
Figure 6: The System Profiler UI.
In addition to the data available in systrace, AGI also shows GPU
performance information. For more information about viewing system profiling
data, see View an AGI system profile.
To profile an individual frame from your app, perform these steps:
In the AGI launch screen, click Capture a new trace to display the
Capture A New Trace dialog. Alternatively, you can click the
Capture Frame Profile trace button.
In the Type list, select Vulkan or OpenGL on ANGLE depending
on which Graphics API your app uses. Make sure you're choosing the right
one, otherwise AGI won't capture any graphics commands.
In the Start and Duration section, set Start at to Manual. If
you clicked the Capture Frame Profile trace button, this step is already
completed.
In the Output section, select an Output Directory to store the
trace files. The File Name field should be auto-filled, but you can
also edit it.
Optional: Some apps spawn a different process that does all the graphics
processing. To capture that process, specify its name.
Click OK. This starts your app on the Android device, and displays a
pop-up window with a Start button.
Click the Start button and wait a few of seconds for profiling to
complete.
Click Open Trace to view the profiling data. For information about each
pane in the Frame Profiler UI, see the
Frame profiling overview.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022年03月15日 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022年03月15日 UTC."],[],[]]