Performance profiling and tuning is a complex task that can feel more like an art than a science. The many moving parts that need to be perfectly synchronized in a game combined with the complexity in a given scene can make understanding and isolating problems difficult. On ChromeOS, many tools are designed with ARM chipsets in mind. Below are some tips to help speed up the process.
Something to keep in mind when specifically optimizing your game’s performance on ChromeOS is that the underlying performance issues are shared across all devices, and improvements will benefit performance and battery life for all users. ChromeOS, with a tendency for larger displays and desktop input devices, may just surface certain issues more readily. For example, an inefficient texture loading algorithm may “work fine” on higher end mobile devices, but not be able to keep up on a Chromebook with a 4k display. Improving the algorithm will improve the game on all devices.
If you are new to profiling, a good general approach is to:
- Determine if performance is bound by:
- Other: Input/Disk/Network
- Try to isolate the major cause
- Try to optimize
In most cases, games will show themselves to either be “CPU-bound” or “GPU-bound”. Using the profiling tips and tools below, attempt to determine where the system is “spending it’s time” each frame. For example, if it is taking a long time calculating and loading the vertices before the GPU begins rendering, your game may be CPU-bound. Instead, if you are using a large number of detailed, GPU based filters, your game is likely GPU-bound. Remember that many mobile phones and ChromeOS devices do not have discrete graphics cards. A desktop game that assumes GPU filters are fast, may find integrated GPUs taking too long to render each scene.
For more details on how to approach profiling, check out ARM’s guide on ‘The optimization process’.
While it’s certainly possible to determine bottlenecks on your own, having the right tools will make analyzing your game’s performance easier and will give you confidence that you’re focusing on the right things. There are many tools out there, but here are some of our go-to programs.
The easiest way to start profiling any Android app is with the integrated Android Studio profiler. From Android Studio, instead of hitting “Run”, simply choose “Profile” to run your app and get real-time insight into CPU, memory, and network usage. Simple CPU traces can be a quick way to isolate areas of code to look at.
This tool does not grant real insight into GPU usage nor into what is happening between each frame sync so, while a good tool to have in the toolbox, is likely not going to be sufficient to get your game running at peak performance.
Because your games behaviour will be the same across devices, one good way to get detailed performance information is to use the Snapdragon Profiler on a Qualcomm based, ARM phone. Although not directly profiling on a ChromeOS device, this should give you information about where your game is spending most of its time each frame, and can give you insight into specifically which GPU calls are being used.
For example, if you see that a large amount of time is being spent in your anisotropic GPU filters and it is dominating the work being done each frame, you can likely make some large performance gains by changing this setting.
If you see the GPU times are short and regular, but the CPU times are dominating and causing you to miss frame syncs, take a look at your texture loading/frame preparation algorithms.
See the official usage documentation for more information.
The Android GPU Inspector is a new tool developed by Google and specifically designed to help you get the best performance out of your game with both OpenGL and Vulkan. It is currently in a developer preview state and may take some work to get set up and is currently only working on a handful of devices. It promises to be one of the major tools to use for graphics profiling in the future. See the official documentation.
ChromeOS has a built-in graphics profiler that helps you understand how your Android game is interacting with the desktop compositor. It can help you get a global view of the operating system and see if glitches are occurring because your game is not producing frames fast enough or if other pieces of the system are utilizing the CPU. You can include custom tracing tags in your app to narrow down which parts of your code are responsible for missing rendering windows.
Start the tracing tool by navigating to
chrome://arc-graphics-tracing in the browser on ChromeOS. Detailed usage instructions can be found on debugging animation jank.
There’s also a more generalized tool - ARC Overview Tracing - that works similarly to the above ARC Graphics Tracing tool. This tracer will provide high-level metrics about an app and ChromeOS performance. Read outs will show you FPS of the app and of Chrome itself, as well as CPU usage, GPU usage, power consumption, and more. You can run the tool multiple times and see graphs for each run overlaid together with colors to differentiate them. Each tracing model will be saved to your Downloads folder and can be reimported for future comparisons. For general app health checks, ARC Overview Tracing is a good place to start.
chrome://arc-overview-tracing in the browser on ChromeOS to access this tool.
So maybe you’ve found some bottlenecks but are not sure what to do about them. Or you’ve found and addressed them, but you’re not sure where to go next. Below, we’ve compiled a list of general Android and engine specific tips and resources for you.
The Android Developers portal has some great tips for boosting the performance of your application. Load time considerations, how to utilize multithreading, handling input lag, and more can be found there.
Remember to profile early and profile often, especially if you are targeting less powerful machines or pushing the boundaries of high-end architecture. Keeping track of your app’s performance stats will aid you in identifying which changes tanked your frame rate and which are helping you maintain that smooth experience you’re aiming for.
On top of their general Android docs, Unity provides Chrome OS-specific docs to help you create a performant ChromeOS application using their engine. Check out their ChromeOS docs on getting started, input, debugging, and building which includes how to create x86 builds. For their content on performance, see understanding optimization and their course on performance and optimization.
Consider reading ARM’s guide on profiling and optimizing Unity games and their associated best practices. This will lead you through the process of profiling an example game in Unity with the Streamline tool, a facet of the ARM Mobile Studio.
Unreal has written it’s own performance guidelines and tips and tricks docs that teach you how to best leverage many of the options and settings that the engine provides. Here you’ll find things like Level of Detail tricks, how to get the most out of lighting, step by step guides on material quality settings and shaders, among other suggestions.
For more graphics based optimizations, ARM has written a guide for optimizing mobile games. General optimization tips as well as Unreal specific graphics considerations can be found here.