June 23, 2017

Optimize Your Unreal Engine Applications for Mobile with ARM's Mali Graphics Debugger

By Thomas Poulet

The ARM Mali Graphics Debugger is a tool that helps you optimize your graphics applications for mobile platforms. From UE4.15 onwards, using the Mali Graphics Debugger with your project is as easy as selecting an option in your project settings window. With Unreal Engine 4.15, Epic Games introduced the ability to directly enable profiling on mobile devices from the editor. In a previous blog article, we discussed how to enable this feature on pre-4.15 engine versions. The following content applies to 4.15 onwards, and this article was written using Mali Graphics Debugger version 4.5.

During the Unreal Engine livestream, ARM’s engineers demonstrated exactly how to implement and use the Mali Graphics Debugger with UE4 to debug an Android device. Using a Samsung S7, they were able to show the device and debugger running in real time to optimize the project.
 

Activating the Mali Graphics Debugger has never been easier. From now on you will be able to activate it simply by selecting the option in the project settings window. The first step is to open your project, then open the Project Settings window. From there, in the left menu, find Android listed under Platforms. In the body of the menu, in the Platforms section, find the Graphics Debugger section. Finally, select Mali Graphics Debugger rom the dropdown menu.
 
Project Settings

Once selected, you will have to enter the path to the Mali Graphics Debugger installation on your host computer. In order for this to work, you will need to have a working version of Mali Graphics Debugger installed on your system. More information on how to install it can be found here.
 
Settings

The next step will be to install the MGD Daemon onto your target device. To do this, locate the MGD installation folder and inside target\android\arm install MGDDaemon using the following command:
 

adb install -r MGD.apk


Before running your app you will need to run this command from the host PC (please ensure that the device is visible by running "adb devices" command first):
 

adb forward tcp:5002 tcp:5002


Run the MGD daemon application on the target phone and activate the daemon itself:
 
blogAssets%2F2017%2FJUNE+2017%2FARM+Mali+Graphics+Debugger%2FMALI_03-320x210-7e86bc8fd2479e24c233f50700f517cf87746029

At this point you can connect your device to MGD on the host PC, start your application and begin debugging it. Please refer to the MGD manual for more in-depth information on how to use it.
blogAssets%2F2017%2FJUNE+2017%2FARM+Mali+Graphics+Debugger%2FMALI_04-320x179-5be378c8e481d239e3386e90be947ce82142328b
Mali

In some cases where you have really complex applications, your game thread may timeout waiting for the render thread. You will eventually see this in the log (you can access the log with the command 'adb logcat –s “UE4”' ):

GameThread timed out waiting for RenderThread after 30.01 secs


In this case, simply run this in Unreal console (4 fingers tap by default), to disable timeout:
 

g.TimeoutForBlockOnRenderFence 9999999


Following these steps, you should be able to use Mali Graphics Debugger with Unreal applications on any Mali based platform. If you have any issues please raise them on the community pages and someone will be more than happy to assist you through the process.