BKWLD

 

Flash player crashes browser when closing window (possible fix)

By Ben on November 21, 2007 at 9:29 am

Working with ActionScript 3, we’re finding plenty of bugs that others have found and have experienced some intermittent crashing due to garbage fonts, but yesterday we had a doosy that lasted all day. The site was running fine and frame-rates were great, but we could pretty consistently crash (or at best get a spinning color wheel on ) any browser (safari, firefox, ie 6 + 7, mac, windows) when you closed the window containing the flash movie (closing the browser window with a hot key or clicking the close button). We started by removing all our code; first papervision code, then removing the content that was being displayed, then all embedded fonts … it was pretty stripped down. It was not until the content was removed that the browser crashes subsided. So, we started googling the hell out of “flash player 9 crashes closing window” and randomly came across this post where user nikonratm noted the following:

Tweening the position of a TextField that has a mask, as soon as I close the movie window the program crashes, whether it be in the Flash (CS3) IDE or in a browser.

This was the first instance we had found where the crash was specific to closing the window. So, we went through and removed all masking and no crashes. We then added each mask back and tested and got to a point where we slimmed down the crash culprit as a directly masked text field that had a TextFormat applied to it (also it had embedded fonts, not sure if that had anything to do with it), i.e. a TextField that had a mask applied to it and not a DisplayObject containing a text field with a mask appled to the DisplayObject. You always had to put text inside MovieClips to dynamically mask in AS2 so it seems that either the implementation is faulty in AS3 or just moving or changing the text after it has been masked causes some kind of memory leak (which causes the browser to crash on close). Something like this:


var titleMasked:TextField = new TextField();
titleMasked.mask = gradient;

Perhaps a fix would be to put the text inside a sprite (at this point, I’ve spent so much time I’m not bothering to test it):


var titleSprite:Sprite = new Sprite;
var titleMasked:TextField = new TextField();
titleSprite.addChild(titleMasked);
titleSprite.mask = gradient;

To fix some of these issues, Adobe seems to think downgrading to flash player 8 is a good idea. Should we also go back to AS2 while this is resolved? I’m ready to after yesterday. Their solutions to bugs leave something to be desired. For example, one of their comments regarded the Loader classe’s inability to close streams when uploaded:

You cannot expect an “unloaded” movie to close its net streams automatically.

Well, it may not close the stream automatically, but if you create method called “unload,” I’m going to have the expectation that it’ll unload something. Perhaps there’s an undocumented unloadAndCloseStreamAutomatically.

6 Comments »

  1. I am also experiencing similar issues. Whenever flash 9 is installed, any exit directly from a site that called the flash causes IE6 to crash. If I navigate away from an offending site, then exit, all is well.

    I am using the tool from Adobe to uninstall flash, but the whole process is a pain. major.

    Comment by Tom Hvizdos — December 19, 2007 @ 2:10 pm

  2. It’s February of ‘08 now and I just came across the problem myself. Come on, Adobe! This thing drove me INSANE for 3 days when I hit a roadblock in an app I’m developing. By sheer luck I came across the post you mention, and figured I’d give it a try. I was out of ideas, anyways. And it worked!
    And you’re right about the memory leak. Before removing the textfield masks, I had considered a leak and was tracking the total memory usage. While the garbage collector works as it should during runtime, the mem usage would slowly (and I mean slowly) creep up indefinitely. Once the masks were removed, however, this was no longer an issue. I wonder if the masks are never truly removed from the stage when its corresponding textfield is removed. It’d seem especially strange, since my textfields were inside a parent MC that was removed entirely.
    Adobe’s got some ’splaining to do. >:( But I’ll be damned if I’m going back to AS2 and AVM1.

    Comment by Corey — February 17, 2008 @ 7:40 am

  3. I love you guys. I found this site after FINALLY narrowing this issue down to the masking of the text field. I just wrote a wrap around class that extends Sprite and get/sets all the text attributes for my field. I’m thinking about taking the time to create an example project that shows this consistent issue to Adobe and submitting a bug report. Has anything of this nature been done that you know of? Thanks again for the resourse!

    Comment by Jay — March 3, 2008 @ 6:16 pm

  4. After half a week of building and rebuilding, I also managed to narrow down. I was planning on either
    1)skipping my nicely tweening textfield
    2)skipping embedded text: not really an option
    3)going back to as2
    Hope everything is gonna be fine now.

    Thank you guys, i thought i was the mad one!

    Comment by Moose — March 25, 2008 @ 7:55 am

  5. Thanks for that. You’re fix is working and stops flash to crash on exit.

    Comment by Oli — June 18, 2008 @ 4:30 am

  6. Thanks for this, i’ve spent the last couple of days figuring out what was going on here.

    In my case it was an externally loaded swf and i guess instead of closing the window it occured when unloading the external swf (this was part of my main navigation for a website). I didnt have to even refresh, just press the link repeatedly and eventually it would just crash firefox and the flash IDE!

    What a strange bug and what a waste of my time…

    (oh and we’re in sept ‘08, still not sorted ey….)

    Comment by Ross — September 10, 2008 @ 9:22 am


RSS feed for comments on this post. | TrackBack URI

Leave a comment