1
votes

since updating my Flash Player plugin from 10 to 10.1, I'm seeing a weird crash when accessing shared objects. Flex Builder's debugger pops up and prints a stack trace like this:

undefined

 at flash.net::SharedObject$/getLocal()
 at my.code::MyClass$/load()[/my/path/to/my/MyClass.as:27]
    (...)

This happens when calling SharedObject.getLocal("someString") for the second time for the same string, though it doesn't always crash. When using another browser on the same machine (not configured as the preferred debugging browser in Flex Builder), Flash Player remains silent. The code is wrapped in a try/catch(Error) block which does not catch this error. I'm using Flex SDK 3.5 and Flex Builder 3 on Mac OS X 10.6.3. Has anyone else seen this?

Thanks, Simon

4
Please file a Flash Player bug asap: bugs.adobe.com - James Ward
Can you provide a link to the bug report? Can't find it on Adobe's JIRA. Ta! - Juan Delgado
I'd love to, but Adobe considers the bug report as too confidential for the general public (including me...) - Simon
Sometimes crashes can be security problems. So they initially make these types of bug reports hidden while they evaluate if they pose security risks. - James Ward
I'm seeing this too, except with SharedObject.flush. I'm using Safari 5, OS X 10.6.3, SDK 4.0 and FB 4. My app makes about a dozen calls to SharedObject.flush on startup, but only a few of those calls make the debugger stop. Haven't found a pattern yet. - Wade Mueller

4 Answers

3
votes

Here's a work around:

    package scolab.core
{
    import flash.net.SharedObject;

    /**
     * Flash 10.1 introduce a nasty bug that crash the FlashPlayer and the browser when a SharedObject is accessed consecutively
     * We work around this issue with a static accessor that make sure the SharedObject is accessed only once and kept in cache.
     * */
    public class SharedObjectManager
    { 
        private static var cache:Object = new Object()
        public static function getLocal(name:String, localPath:String = null, secure:Boolean = false):SharedObject {
            if (cache.hasOwnProperty(name+":"+localPath+":"+secure)) {
                return cache[name+":"+localPath+":"+secure]
            } else {
                cache[name+":"+localPath+":"+secure] = SharedObject.getLocal(name,localPath,secure)
            }
            return cache[name+":"+localPath+":"+secure]
        }
    }
}
4
votes

I'm not getting any errors, flash just seems to run an infinite loop and crash my browser. Works fine in Safari but not in Firefox 3.6.8.

I fixed it by doing the following:

var mySO:SharedObject = SharedObject.getLocal("mySO");
mySO.flush();      // Fixes Firefox shared object bug

My best guess, it's trying to continually load a shared object that doesn't exist.

1
votes

I've got the same issue and figured out that main reason for that are multiply LSO with the same name. Just make sure that you have only one instance of the SharedObject with particular name.

public class LsoManager
{
   private static var _collection:Dictionary = new Dictionary();
   private static const LSO_LOCAL_PATH:String  = "/";
   private static const LSO_USE_SECURE:Boolean = false;

   public function LsoManager() 
   {}

   public static function get(key:String):SharedObject
   {
        if (!_collection.hasOwnProperty(key)) {
            _collection[key] = SharedObject.getLocal(key, LSO_LOCAL_PATH, LSO_USE_SECURE);
        }
        return _collection[key];
   }

}
1
votes

I too was burned by this problem upon upgrading to FlashPlayer 10.1. On my machine (Mac OS 10.6.4, Firefox 3.6.6, Flash Builder 4, Flex 3.2), no stack trace was reported... the browser just hangs.

I was able to work around this problem by making sure I called SharedObject::flush() every time I modified a property of the SharedObject.data object:

var so:SharedObject = SharedObject.getLocal("blah");

so.data.something = "abcdef";

// not so.data.flush() - there is no such method
so.flush();    // this fixed my problem on FlashPlayer 10.1

I see a commenter above mentioned that it was the flush call itself that was hanging, so YMMV.