I’ve just wasted quite a few hours getting the Flex Profiler to work, and maybe I can share my dearly earned knowledge on the subject. So first, a few words on how the profiler works:
The profiler is a part of the Flex Builder IDE, that listens for messages from the profiler agent. The profiler agent is a swf launched in parallel to your main swf. It is located in your Flex workspace at .metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf. Your IDE gets this agent to start by editing your mm.cfg and adding a “PreloadSwf” line. The agent uses the flash.sampler.* API to gather data on your main swf, and sends it to the IDE using TCP on a preconvened port. This port is 9999 by default, you can change it in Preferences/Flex/Profiler/Connections.
Now, where can this stuff mess up?
- your firewall can be blocking the communication. Make sure it lets the info through!
- your IDE doesn’t edit your mm.cfg file properly. This is completely undocumented, but adding the info manually works. I added the following line to the file:
PreloadSwf=D:/ariel/projets/client/flex/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&port=9999
- you got the the path to the profile agent wrong. You can check this by looking in the flash text logs. If the preload went wrong, you should see a message like
PreloadSwf paths must be local trusted: D:/ariel/projets info/repository/client/flex/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&port=9999
right at the beginning of the file.
- You’ve gotten so far and are ready to give up all hope? Fear not, I have one more completely unexplained hack for you: try another browser. In Preferences/General/Web Browser you can change the browser used at launch. Somehow Firefox wasn’t working for me, so I tried with Internet Explorer and it worked. Don’t ask…
Some thoughts on the mess: Adobe, you have a very useful, free profiler. But WTF? I had to scour the net for hours to gather this info! We need documentation! The source to the profiler agent would be nice. I suppose I could decompile it now that I know where to find it, but still… The community could contribute to improving both the agent and the ide part.
And finally, some references:
- The only article I found about the profiler written by someone who has something to do with it :
http://stopcoding.wordpress.com/2008/04/26/lets-talk-about-the-flex-profiler/
- where is your mm.cfg file?
http://livedocs.adobe.com/flex/3/html/help.html?content=logging_04.html Note that there is no mention of PreloadSwf
- a post in french that tipped me off about editing the mm.cfg file manually.
http://flex.mediabox.fr/index.php?showtopic=72928
If you’re having some trouble, feel free to ask some questions, I’ll try to help. I feel for you. Really.
Pingback
by Retour d’expérience #2 : Flex
05 Jan 2009 at 21:40
[...] à la mano. Et quand vous aurez codé 6 mois sur votre application vous pourrez même découvrir le Flex profiler, embarqué dans l’IDE, qui vous permettra de détecter les fuites mémoires [...]
by Richard
12 Mar 2009 at 03:04
Excelent. This has been bugging me for a while.
I had a file, but as I had moved my Users home directory to my D drive, d:\users\user_name (im on vista) the profiler didnt pick it up. When I created the file on my c drive c:\users\user_name\mm.cfg and put path in to my PreloadSWF the profiler started. But now, any other flash files that I view try to start up the preloader.
by admin
12 Mar 2009 at 11:06
Hi Richard,
if this bothers you then the only solution I can think of is to remove the line from mm.cfg and put it back only when you want to profile. Not ideal, I know, but then you can always file a bug at Adobe so that they fix this for Flex 4!
let me know how it goes
Ariel
by dunkelfuerst
14 Mar 2009 at 18:03
Woohoo, you saved my life. =D
by admin
14 Mar 2009 at 20:42
Ich freue mich das ich dir geholfen habe
by Justin J. Moses
26 Mar 2009 at 05:53
Thanks for the post – FB3 couldnt profile AIR but it could to Flex…
I eventually solved it by editing the mm.cfg file that was in my local user home (C:\documents and settings\jmoses) as you mentioned above and then copying it into the mapped H:\ drive that was my shared “My Documents” folder (%HOMEDRIVE%%HOMEPATH%).
by Mark Luki
02 Jun 2009 at 23:38
Thank you for this post. It’s been driving me nuts. All of a sudden the debugger stopped working. I couldn’t get the profiler to work yet, tried all your suggestions above. The debugger does work again though. At least that…
I really wish I could make use of this profiler. It looks very helpful…
My regular local MAMP port is 8888. When I use the same port for ProfilerAgent.as in the mm.cfg file the browser crashes or gives me an error message.
Error: ProfilerAgent.socketDataHandler: unknown command = 60
at ProfilerAgent/socketDataHandler()[C:\faramir\flex\sdk\modules\profiler3\as\Prof ilerAgent.as:1008]
When I switch the port to 9999 the debug works but the profiler doesn’t show anything.
I’m on a Mac, Flash Player 9 (debugger), Flex Builder 3, actionscript project.
Any insight or help on how to get the profiler to work would be much appreciated….
by admin
03 Jun 2009 at 11:37
Hi Mark,
if you use the same port then MAMP and the profiler are speaking on the same port, and I’m not surprised that it crashes. In preferences -> Flex -> Profiler -> connections you can set the port for the profiler. One more thing: You can’t debug and profile at the same time. Hope this helps…
Ariel
by Mark Luki
03 Jun 2009 at 15:09
oh I see… I am using port 9999 now and you’re right it doesn’t crash! Thank you!
After hitting the profiler button the browser starts and a window appears (Configure Profiler > Connection established). The first info “Connected from” is currently set to the wrong website. I assume it should be localhost or localhost:8888?
Anyway do you have an idea where can I change this setting?
-ml
by Mark Luki
03 Jun 2009 at 15:30
Hi Again… sorry I forgot to mention in my previous post that the profiler still doesn’t work though… It doesnt crash things and the debugger works but the profiler doesn’t display any information. No classes or objects…?
by admin
03 Jun 2009 at 16:20
First question: In preferences -> Flex -> Profiler -> connections you can set the port for the profiler. Did you try this?
2nd question: You should be seeing some classes, objects etc. Try disabling some options, maybe you’ll get some results.
by Nino
04 Jun 2009 at 06:55
wow this saves my day. I just modified the mm.cfg and everything works!
by admin
04 Jun 2009 at 09:57
glad I could help
by Ziv
07 Jul 2009 at 15:59
Full solution:
While I try to run my Flex Profiler I got this error message:
In the flash application I got the following exception:
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C|%2Fwork%2Flabsense%2Fbranches%2Frel%5F1%5F2%5F5%5FEA%2Fsources%2Fui%2F.metadata%2F.plugins%2Fcom.adobe.flash.profiler%2FProfilerAgent.swf?host=localhost&port=9999 cannot load data from localhost:9999.
at ProfilerAgent()[C:\SVN\branches\3.2.0\modules\profiler3\as\ProfilerAgent.as:127]
And in the flex Profiler console (at the eclipse) I got : Socket timeout.
I am run on windows vista,
Flex builder: 3.2
Flash debugger : 10,0,22,87
Things that I have done to resolve this issue:
• Switch the connection port of the profiler to 9998 (and back)
• Remove and reinstall the flash debugger player.
• Install flex builder 3.2 (instead of 3.0)
• Delete all the enters in the mm.cfg file
• Add enter to the mm.cfg : PreloadSwf=C:\work\labsense\Sources\ui\.metadata\.plugins\com.adobe.flash.profiler\ProfilerAgent.swf?host=localhost&port=9999
or
PreloadSwf=C:\work\labsense\Sources\ui\.metadata\.plugins\com.adobe.flash.profiler\ProfilerAgent.swf?host=localhost&port=9998
or
PreloadSwf=C:/work/labsense/Sources/ui/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&port=9999
or with spaces:
PreloadSwf=C: \ work \ labsense \ Sources \ ui \ .metadata \ .plugins \ com.adobe.flash.profiler \ ProfilerAgent.swf?host=localhost&port=9999
or
C:\work\labsense\Sources\ui\.metadata\.plugins\com.adobe.flash.profiler\ProfilerAgent.swf?
or add all or some of the enters:
TraceOutputFileName=C:\Users\zivo\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt
ErrorReportingEnable=1
MaxWarnings=0
TraceOutputFileEnable=1
ProfilingFileOutputEnable=1
• Turn on and off the vista firewall
• Add exception for port 9999 in the vista firewall
• Try to run the profiler SWF separately
Same result.
Try one last thing:
Because I have expreins problem little bit similar before with the flash debugger , the resolution then was :
1. Right click on flash player (debugger),
2. choose “Debugger”,
3. choose “other machine”
4. add “127.0.0.1”
5. click ok
then, it solve the issue (but apparently he connect to the debugger with host 127.0.0.1 instead of localhost (which is a same )
I now add to the mm.cfg file, the follow entry:
PreloadSwf=C:/work/labsense/branches/rel_1_2_5_EA/sources/ui/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=127.0.0.1&port=9999
Then, after saving , I run the profiler, and its work!!
And the resonse for all this was :
Some program change the file:
C:\Windows\System32\drivers\etc\hosts
To:
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
::1 localhost
127.0.0.1 iDBO # LMS GENERATED LINE
This means that localhost is not lead to 127.0.0.1!!!
Fixing is easy :
# ::1 localhost
# 127.0.0.1 iDBO # LMS GENERATED LINE
127.0.0.1 localhost
Instead (remark the problem and fix the problem
Thenks
Ziv
by mark
03 Oct 2009 at 14:09
thanks!
had problem getting the flex profiler to work, was always giving the unable to connect issue.
opened up the mm.cfg file, realised it was corrupt, deleted it so a new one was created the next time I ran the profiler and all was good in the world again =)
cheers
by admin
03 Oct 2009 at 14:52
you are welcome
by Federico Calvo
16 Nov 2009 at 23:36
Thanks for this, it pointed me the right way. Didn’t work though until I typed the ProfilerAgent.swf path like so in the mm.cfg:
PreloadSwf=file:///C:/Users/fede/!work/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&port=9998
by admin
17 Nov 2009 at 09:30
Hi,
funny that you should have to use that syntax for the path. Anyway, I’m sure that will help others!
Ariel
by Shiyaz
07 Dec 2009 at 09:21
@Federico Calvo, thanks man. Strange, but your solution worked.
I had no problem until yesterday, I used *CCleaner* to cleanup some stuff. I guess some of my config files, or whatever, got altered (?). Then, when ever I open PMD Viewer reports of my project, this error gets thrown.
In fact, even when I open another Adobe product RoboHelp 8, it gives out this error, whenever I click any link from the Project Setup pane.
I had to add *file:///* to the path in mm.cfg as you had suggested (PreloadSwf=file:///C:/Users/…..) and the error stopped. However, my port is still configured to 9999.
Thanks,
Shiyaz
by II
10 Dec 2009 at 18:51
This website has some ideas: http://wceii.blogspot.com/2009/12/flex-profiler-socket-timeout-error.html
by admin
10 Dec 2009 at 19:02
Hi II,
who knows, it might help someone so thanks
Ariel
by Tom
15 Jan 2010 at 17:48
Thanks for the info above, although none of its working for me
Using flashBuilder 4, trying to profile a flash 9 swf compiled in CS4
My mm.cfg is updated correctly with the location of the PreloadSwf, however when the profiler launches i get the following in a popup
“Unable to connect to the application to fetch profile data. Please try profiling the application again.”
Any ideas whats up?
Thanks in advance
Tom
by NewFlexDeveloper
18 Jan 2010 at 11:13
Hi,
First of all let me take this opportunity to thank you for the article.
I have followed everything that you have mentioned in your explanation. But I still am getting a Socket timeout message in the console window in the profiler view of the FB3 IDE.
Have checked the firewall, mm.cfg file the path to the profiler agent swf file and the port number.
Please help!!! I need to use the profiler for some memory issues.
Thanks.
by NewFlexDeveloper
18 Jan 2010 at 13:57
Another bit of information I think could be important is that I am trying to profile ans AIR app.
Thanks in anticipation.
by NewFlexDeveloper
20 Jan 2010 at 11:04
I have finally got the notorious Flex Builder profiler working!! woohoo…..
Well, I did try all of the things that were mentioned above right from the mm.cfg file and upto installing the debug version of the Flash player.
None of this worked. But what actually worked for me is this:
(I am using a Window XP SP3 machine.)
I created the mm.cfg file but to that I gave the default path of the Adobe flex builder for the ProfilerAgent.swf.
(Default path is the one that Adobe Flex Builder 3 refers to as the default workspace once it is installed – C:\Documents and Settings\Administrator\My Documents\Flex Builder3\.metadata\.plugins\com.adobe.flash.profiler\ProfilerAgent.swf).
This path is also found mentioned in the Flash player folder in the folder under Application Data dir.
The path to the same is – C:\Documents and Settings\Administrator\Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust\flexbuilder.cfg – this file has the path mentioned to the profilerAgent.
I hope this does help!!!
Thanks again.
by admin
29 Jan 2010 at 10:28
you’re welcome
Sorry I didn’t get back to you, it appears my server’s alert system is wonked out, so I wasn’t getting the emails. Glad you made it anyway!
by Sriram
29 Apr 2010 at 16:54
Hi Ariel,
I am stuck with this issue for the last few days .
I have a FLEX Application that requires Flash Player 10. I have installed the debugger for the same and followed the steps as mentioned by you …
When i launch the profiler the error i get is
ReferenceError: Error #1065: Variable ContextMenuClipboardItems is not defined.
at flash.ui::ContextMenu/initLinkAndClipboardProperties()
at flash.ui::ContextMenu()
at mx.core::Application/initContextMenu()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Application.as:1154]
at mx.core::Application/initialize()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Application.as:844]
at Application/initialize()[E:\eclipse-3.4\workspace\ui\src\flex\Application.mxml:0]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2043]
at mx.managers::SystemManager/initializeTopLevelWindow()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:3279]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:3103]
at mx.managers::SystemManager/docFrameListener()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2955]
I am completely lost and have no idea … It would be great if you can guide me …
Thanks & Regards,
Sriram
by admin
29 Apr 2010 at 16:58
@Sriram. I’ve never seen such an error, so I’m not sure I can help you. Does your program work normally when you run it without the profiler?
by admin
29 Apr 2010 at 16:58
@Sriram again. What happens when you create an empty flex project and you try to profile it?
by Sriram
29 Apr 2010 at 18:03
Hi Ariel,
Thanks a lot for your quick resposne.
The app works fine with Normal Launch Run mode or in Debug mode. It is only the profiler who seems to be unhappy with me
I worte a very small custom application. Setting the tragte player to 9.0.28 profielr works. Once i change it to FLEX 10.0.0 i get the error.
I am using FLEX 3.3 SDK and FLEX Builder Version 3.0.
Thanking you in advance …
Thanks & Regards,
Sriram
by Aaron Hardy
07 Jun 2010 at 21:22
Thanks. The mm.cfg entry worked for me.
by Aaron Hardy
07 Jun 2010 at 21:37
Scratch that. It’s back to haunt me some more.
by Sarbakan
07 Jul 2010 at 18:39
hi everyone, since some days i tray without success to make the profiller for flash builder 4 to work without any chance.
i got the “unable to connect to the application to fetch profile data” error. i try many things mentioned here and nothing work : changing port, add line in mm.conf, reinstall, reboot, change of computer, i even try on a fresh new windows installation but nothing change.
NOW i try this: we are on a domain and i try to log my computer on a local administrator account instead of logging on a domain account.
IT’S WORKING !!!
so i currently searching what can be the cause of that but i think its maybe a blocked port error or a specific domain policy that cause all that. maybe together we are gonna find what causing all of this
by sarbakan
07 Jul 2010 at 21:29
i finally found what the problem was:
i use wireshark to capture the network traffic and compare what the difference between the local computer account and the domain account and find that when i was in a domain account the flash builder programs was searching the mm.cfg file inside the user network drive.
we all have an network drive for personal storage and after i copy the mm.cfg to the user network storage the profiler work fine. but now the debugger start to have problem.
so i just create a .bat file to rename the mm.cfg to mm.bck and one to restore it.
So everyone having problem try to use Wireshark to see if is not searching for the mm.cfg at the wrong place.
you should see
NT CREATE ANDX REQUEST PATH :\folderwherehelook\mm.cgf
NT CREATE ANDX RESPONSE STATUS_OBJECT_NAME_NOT_FOUND
P.S. its fix our flex3 and flash builder 4 profiler problem
by admin
19 Jul 2010 at 11:14
er… I never heard of that one. Let us know if you find something
by Matt
02 Aug 2010 at 18:56
sarbakan – you saved me a lot of pain!
My issue was exactly as you said. Wire shark showed it was looking for the file on my personal storage on the network, NOT in my local user dir.
Interestingly, it did write to the file in the local dir, but still failed. Placing a copy of this on my network personal drive, with the preLoadSwf path data in worked a treat.
by sarbakan
06 Aug 2010 at 17:15
the problem seem to happen to people that have set their homepath (in active directory ) to a different location than “C:/document and setting/username/”. flash is editing the mm.cfg on the document and setting to bring the profiler on but the application try to use one on the homepath directory. switching back to flash 10.00 correct the problem so probably a new version of 10.1 will make a difference. i post about this on the adobe forum thread http://forums.adobe.com/thread/657773?tstart=0
i hope adobe will do something for that
by Ivan Slepchenko
25 Aug 2010 at 22:08
After all these fun with mm.cfg and firewall and hosts file and other,
the only thing that helped me – removing
wmode=”transparent”. This is not a joke!
by admin
26 Aug 2010 at 12:22
wow, that’s a new one