tags:

views:

581

answers:

3

Hi all,

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

+1  A: 

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]
        }
    }
}
Guillaume Malartre
Sweet, thank you for sharing :-)
Simon
+1  A: 

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";

so.data.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.

onehorsetown
+2  A: 

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.

Maxsquatch
This bug applies to more then just FF, I'm getting the same problem in Safari, one file hangs (with no flashplayer errors presented, requiring a force-quit), other file (with same html container) doesn't. Quite confusing, but immediately calling mySo.flush() after creating the So fixes the problem.
Nilloc