AMP User Guide

AMP™ is the Scaleform® remote profiling system, capable of monitoring CPU usage, graphics rendering, and memory consumption of a Scaleform application. Real-time graphs provide a method of quickly identifying memory and performance bottlenecks, and per-frame statistics allow an in-depth analysis and determination of the causes. AMP can also help find script problem areas, using its per-frame ActionScript function and source code timings.


Figure 1: Scaleform AMP

Every Scaleform application can act as an AMP server, which means that it listens for incoming connection requests by the profiler, gathers information every frame, and sends it to the profiler over the network. The profiler acts as an AMP client, which means that it connects to a specific AMP server, processes the information sent from the server every frame, and sends requests to control the profiled application.

AMP is available with Scaleform 3.2 and higher versions.

AMP Server

A Scaleform application being profiled (the AMP server) sends a certain amount of information over the network to the profiler. Depending on the level of function profiling, each ActionScript function and some important C++ functions may be timed. If per-line source code profiling is enabled in ActionScript 2, each ActionScript bytecode execution is timed (ActionScript 3 source code profiling does not require timing each execution). In addition, rendering statistics, detailed memory heap and image information, flash file information, and ActionScript markers are recorded. Note that this extra work per frame can slow down the application and increase its memory consumption, especially if per-line timings are enabled.

In order to keep AMP from interfering with the application being profiled, all AMP server information is kept on a separate memory heap. If the size of this heap exceeds a pre-set limit, the application is paused until the pending frame information is sent over the network and subsequently deleted. Scaleform Shipping builds do not act as AMP servers, and AMP support may be easily disabled for any build within an application, if so desired.

Performance statistics on the server are maintained per Movie. This allows users to easily identify problem spots in the case where there are several views associated with a particular SWF file. It also allows AMP to produce meaningful call graphs for ActionScript execution of multiple Movies on separate threads.

In addition to reporting memory and statistics to the client, the server can be controlled by the AMP client in several ways to assist profiling. For example, the profiler can send requests for wireframe mode rendering, for pausing, fast-forwarding, or restarting the flash movie, for toggling the anti-aliasing and stroke modes, for changing the localization fonts, and for changing the vector graphics’ curve tolerance. Furthermore, the client can toggle special AMP rendering modes to show display performance bottlenecks, such as mask, filter, and pixel overdraw highlighting.

While all the above functionality has been implemented in Scaleform Player, some of it requires application-specific implementation, and may be performed as part of a Scaleform integration. To graciously handle the case where some of these capabilities have not been implemented in a Scaleform application, the AMP server reports the set of supported application control functionality to the client on connection. It also reports its current state (wireframe mode, for example) to the client for visual feedback.

Finally, the AMP server has the ability to send Flash debug information over the network to the profiler, so that source code and per-line timings can be displayed if the client does not have local access to that information. In order for this transfer to occur, the SWD file (ActionScript2) or AS file (ActionScript3) should be in a location where AMP can find it.

AMP Client

The remote profiler (AMP client) is a stand-alone application that connects to an AMP server, receives profile information every frame, and displays this information in a user-friendly way to enable effective analysis of performance and memory bottlenecks. The AMP client has several features that allow developers to view multiple aspects of their Flash assets and identify problem areas:

To set values for all of the above thresholds, AMP reads an XML file, called “adviser.xml” in its working directory. If it finds no such file, all thresholds are set to zero. The user can modify any threshold by clicking the Settings button on the right of the Performance Advisor tab. This brings up the settings dialog:

Clicking OK saves the settings to an XML file that AMP reads next time it is executed. The user may create different adviser settings for different content types, and select the one to be used by loading it from the settings dialog. Launching AMP with a command-line argument of “–adviser ” makes the program read an adviser file other than the default one located in the working directory.

AMP allows the user to customize its appearance. The locations where the toolbars and tabs are docked may be changed by dragging them to their new locations. The tabs and toolbars may be undocked from the application. The sizes of the graphs and the tabs may be adjusted, and the graphs may be either partially or totally collapsed. The state of these UI changes is persistent over AMP profiling sessions, but the user can reset the geometry to its default state from the Reset UI selection in the Window menu.