Troubleshooting ActionScript Code Coverage

Sometimes folks run into situation with ActionScript code coverage plugin-in where the SWF files doesn’t make a connection. When this happens the plug-in stays in the “Listening..” status after the SWF is launched in Flash Player or AIR. Usually this happens because one the prerequisites for the tool is not being fulfilled. Before we jump into the diagnosis, lets recap the prerequisites (which are listed in the docs).

Prerequisites:

  • Debug version of Flash Player
  • SWF file that has been compiled in debug mode
  • The preloaded SWF must be local trusted.

Following is how you can ensure that the prerequisites are being met and possible resolutions:

I. To ensure that you are using the debug version of flash player, you can simply compile and run the following mxml code and it should list the version and also if it supports debugging or not:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="application1_creationCompleteHandler(event)">
	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{
				playerVersion.text = Capabilities.version;
				isDebugger.text = String(Capabilities.isDebugger);
			}
		]]>
	</mx:Script>
	<mx:Label text="Version"/><mx:Label id="playerVersion"/><mx:Label text="Supports Debugging? "/><mx:Label id="isDebugger"/>
</mx:Application>

Resolution: Reinstall debug version of flash player.

II. To ensure that you are using the debug version of the SWF, you can run swfdump on the swf file. The swfdump generates an XML report. Look for tags like EnableDebugger2 and DebugID in the report. If these tags are missing then you are probably running a release mode swf.

Resolution: Recompile SWF with debug info. To do this from command line add -debug=true to mxmlc command. To do this from Flash builder, make sure debug is not set to false in additional compiler arguments or a local config file.

III. To ensure that PreloadSwf is local trusted, you can follow the following steps:

  1. Run tail -f command on the mm.cfg file and then click the start button in code coverage plug-in.
    The mm.cfg file is present at the following location:

    XP: C:\Documents and Settings\username
    Vista/Win7: C:\Users\username
    Mac: /home/username or if that doesn’t exist: /Library/Application Support/Macromedia

    After you click the start button, the plugin should add a PreloadSwf entry to the mm.cfg file. If it doesn’t then you should make sure that mm.cfg is writable and that the user has permissions.

    An example of PreloadSwf entry:
    PreloadSwf=/Users/username/Documents/Adobe Flash Builder 4/.metadata/.plugins/com.adobe.flash.codecoverage/CodeCoverageAgent.swf?host=localhost&port=9900&level=0

    Note down the absolute path of folder containing CodeCoverageAgent.swf. It should be in your FB workspace at <workspace>/.metadata/.plugins/com.adobe.flash.codecoverage

    Also the plug-in removes the PreloadSwf entry when you click the stop button

  2. Inspect at the trust files.
    Location of trust file (per-user):
    XP C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust
    Vista/Win7: C:\Users\username\AppData\Roaming\Macromedia\Flash Player\#Security\FlashPlayerTrust
    Mac: /Users/username/Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust

    Location of trust file (global):
    XP/Vista/Win7 C:\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust
    Mac /Library/Application Support/Macromedia/FlashPlayerTrust

    The trust file is usually called flashbuilder.cfg. Make sure that the path of folder containing CodeCoverageAgent.swf is present in the trust file.

Resolution: Add parent folder of CodeCoverageAgent.swf to the trust file. If the trust file is not present create a new trust file. Also it is important to restart your browser/AIR after changes to the trust file.

If all the prerequisites are being satisfied then make sure that the port number (9900) is free for use by code coverage plug-in. In case 9900 is not available then you should update the port number in the code coverage preferences.

2 comments to Troubleshooting ActionScript Code Coverage

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Advertisement

Advertisement