LocalConnection Bug in Flash Player

So I’ve had this problem for ages, and couldn’t find anyone online writing about it.

LocalConnection in AS3 is used to send messages between Flash SWFs in a browser window. It’s also used as a hack to invoke garbage collection in the Flash Player.

I’ve been using it in some recently applications to ensure only one instance of a SWF is loaded at a time on a computer and to display a message to a user if a window with the application is already open.

It’s usually be pretty straight forward.

var LocalConn:LocalConnection = new LocalConnection();

Declares it

			try {
			} catch(error : ArgumentError) {
trace("Uh oh... Looks like it's already running");

Only one connection string can be used at a time, and if another SWF in the another browser window (or another tab… or another browser for that matter) tries to connect that ArgumentError will be thrown.

Unfortunately, there is a annoying bug where sometimes, even if no other instances are open, the LocalConnection thinks someone is still running on the same connection string…

I’ve experienced it happening when simply testing in Flash Builder and FDT… Sometimes I am working on another part of my application when one test the application says it’s already running… I’m confused at this point because I know nothing else is running…

I think I’ve narrowed down WHY it happens. It seems to happen when Flash is closed unexpectedly. For example, on Google Chrome, if you run the SWF and then for some reason Flash crashes (you know… the “uh oh Flash crashed” bar that appears at the top of Chrome), it seems that the LocalConnection is never officially closed.

What sucks is that you either have to change the connection string or reboot your computer (restarting browsers don’t work).

If anyone else has experienced this or knows any fixes, please let me know in the comments. I’ve been experiencing this problem since at least Flash Player 9. I’ve reported it on Adobe’s ticketing system… unfortunately they don’t allow anyone to read the ticket because they restricted viewing deeming it a possible “security” flaw – but maybe if other people are experiencing the issue they will put in a fix for it.

Update 5/10/2011
Qingyan Zhu from Adobe replied to my bug report:

Hi Danny,

Thanks for clarifying the issue.

But this is actually as designed.

So when there’s only one browser, if it crashes, then the segment gets reset, and the dangling LC endpoints get cleared.

But if there are two browser processes (depending, say on how IE is launched), or two processes that use LocalConnection (including any AIR app, Flash Projector, AIM, Y!IM, etc etc), then the corrupt memory segment will stick around.


10 thoughts on “LocalConnection Bug in Flash Player”

  1. Have you tried force quitting the crashed process? That usually solves similar issues for me. I often encounter crashed swfs that have trace statements occurring at regular intervals that spams my trace output. Quitting the containing browser instance via Task Manager on Windows or Activity Monitor on OSX fixes it. Obviously it’s sometimes hard to determine which instance to kill but it beats a reboot IMO.

  2. There isn’t any crashed process to close unfortunately :-(.
    And even if there were… requiring users to do that is not easy. Much easier if it didn’t happen at all…

  3. I had already posted a bug in 2009 to Adobe https://bugs.adobe.com/jira/browse/FP-1775, but unfortunately they closed the bug with no real solutions and no expectation that they should ever fix that. The LocalConnectionINMFix class described in the ticket was solving us lot of problem. The only problem we’ve got is that it make localConnection a assynchrounous call instead of synchrounous call.

  4. Also, instead of rebooting what you have to do to get it works properly is to close all your flash application instance. So all your AIR, browser with flash and flash player needs to be closed. After that you should be able to connect to that channel again.

  5. Yes, but this is very difficult to do.

    For example, I didn’t realize but Skype uses Flash… So I have to quit Skype to ensure Flash completely closes too. I’m sure a bunch of other applications might be using Flash for variety of things.

  6. GOD! All this SUPPOSED “Brain Power” flying around and NOBODY noticed the ERROR in the Intro to “15 Seconds” ???? “all you need, is need a mic” or some BS like that.

    Back to High School JERKS!!

    PS: Danny Miller. Known YOU too long. This doesn’t surprise Me a bit Dyslexia isn’t it???

  7. Ron,
    No idea what you are talking about. If you are referring to the site I cofounded 15Seconds.me and are claiming there is some type of grammatical error on the intro dialog, we couldn’t find one.

    And I don’t know who you are, but I can say I’ve known YOU too long already. What is with the dyslexia insult? I don’t have dyslexia, and I don’t understand the reference.

  8. Hey Danny,

    Thanks for this article. But I do not understand Adobes answer do you?

    Basically, if I use LocalConnection as a “single instance of swf only” and the browser crashes….

    Then it means that by design, there is nothing I can do about it? The user would need to restart the PC in order for the “Dangling local connection” to be cleared?

    It seems that perhaps this system of using localconnection to ensure only a single instance just simply will not work by design. 🙁

  9. Pingback: Anonymous

Leave a Reply to Tim Cancel reply

Your email address will not be published.