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:
- 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/MacromediaAfter 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=0Note 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
- 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/FlashPlayerTrustLocation of trust file (global):
XP/Vista/Win7 C:\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust
Mac /Library/Application Support/Macromedia/FlashPlayerTrustThe 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.
[...] Go here to read the rest: Troubleshooting ActionScript Code Coverage « Gaurav's Blog [...]
Thanks a lot for your help. This article is very helpful. I am successfully able to get the code coverage for my flex applications, but only individually.
Actually I am using virgo web server to deploy my project and then access it via web browser. In case the code coverage plugin is not capturing data. Any help in this case?
FYI – I was unable to get the plugin to work with Chrome. Switching to Firefox cured the problem.
Flash player embedded in chrome is not the debugger version. So it will not work with chrome as a debugger version is required.
Thanks! That makes sense. I’m continuing to have difficulties with the plugin, however. It is only displaying blank reports – sometimes I can get it to work by restarting Eclipse, but it’s very unreliable. When generating a report, the ascc file is populated with the correct XML, but the ascs file is empty. The Eclipse error log shows the following entry:
!ENTRY com.adobe.flexbuilder.project 4 43 2012-04-04 17:00:09.964
!MESSAGE ZIP file must have at least one entry
!STACK 0
java.util.zip.ZipException: ZIP file must have at least one entry
at java.util.zip.ZipOutputStream.finish(Unknown Source)
at java.util.zip.DeflaterOutputStream.close(Unknown Source)
at java.util.zip.ZipOutputStream.close(Unknown Source)
at com.adobe.flash.codecoverage.util.ReportUtil.saveCompressed(ReportUtil.java:398)
at com.adobe.flash.codecoverage.ui.MonitorView$SaveController.doCalculation(MonitorView.java:304)
at com.adobe.flash.codecoverage.util.Calculation.run(Calculation.java:54)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
I’d love to help troubleshoot this – I’ve done a little Eclipse Plugin development myself – but as far as I know, it’s not open-source. Is there any way for me to access the source code?
Thanks!
If nothing else, I’d at least appreciate a reply telling me who is currently maintaining this project, so that I can get in touch with the correct person.
Thanks.
@Tom,
Do you see this will all projects or a specific project? What platform are you on? Do you have double-byte characters in file name?
Please file a bug in JIRA against Flex SDK (Code Coverage component). The plugin is not open-source.
-Gaurav
Hi Gaurav, thanks for the reply. I see this for all the projects I’ve tried it on. I’m using Windows 7 (32 bit), Eclipse Indigo SR1, Flash Builder plugin 4.5, the latest Code Coverage plugin, and Firefox 11. I do not have double-byte characters in a file name. I went ahead and logged a bug in JIRA.