1 2 Previous Next 41 Replies Latest reply on Nov 10, 2009 10:31 PM by Archan144

    Need help diagnosing Stack Overflow error

    emansouri Level 1

      I have an application that loads a HierarchicalData object to the dataProvider of an AdvancedDataGrid.

       

      I build the HierarchicalData object by starting with an Array of Objects, then converting it into an ArrayCollection of ObjectProxy instances.  The manner in which I am doing this is entirely straightforward and I have completely isolated this process away from all other areas of my application and the issue seems related to the ObjectProxy, ArrayCollection, or both.

       

      When I do this, even before passing the ArrayCollection to the HierarchicalData constructor, I get a StackOverflow error.  I don't always get it - that is what is so frustrating about the problem.  The StackOverflow error occurs anytime I try to access the ArrayCollection in any way - even if I just trace() it.

       

      So I have had to resort to simply building an ArrayCollection of Objects and calling AdvancedDataGrid.invalidateList() to update changes to the indiviudal Objects as the ArrayCollection of ObjectProxy's is not working for me.

       

      However, I am still getting random StackOverflow errors.  For instance, I am now getting them occasionally when I call AdvancedDataGrid.calculateDropIndex(DragEvent) within an overridden dragStartHandler() method on the AdvancedDataGrid.

       

      The only information the debugger or a stack trace provides is:

       

      undefined
      at Object$/_hasOwnProperty()
      at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()<http://adobe.com/AS3/2006/builtin::hasOwnProperty%28%29>
      at Object$/_hasOwnProperty()
      at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()<http://adobe.com/AS3/2006/builtin::hasOwnProperty%28%29>
      at Object$/_hasOwnProperty()
      at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()<http://adobe.com/AS3/2006/builtin::hasOwnProperty%28%29>
      at Object$/_hasOwnProperty()
      at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()<http://adobe.com/AS3/2006/builtin::hasOwnProperty%28%29>
      at Object$/_hasOwnProperty()
      at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()<http://adobe.com/AS3/2006/builtin::hasOwnProperty%28%29>
      at Object$/_hasOwnProperty()

       

      I have been struggling with this issue for over a week now and it is greatly hindering my progress on a project so I am hoping someone has some ideas or insight on how I can identify and rectify this issue.

        • 1. Re: Need help diagnosing Stack Overflow error
          eburi Level 1

          --- Double post --- Check next post with attachement

          • 2. Re: Need help diagnosing Stack Overflow error
            eburi Level 1

            Hi,
            I'm experiencing a very similar problem realated to accessing ArrayCollections and I was able to pin it down to the way the swf file is loaded.

             

            The Array access code is as simple as this and works just fine when compiled within a mxml-file with the Flex-Compiler:

             

            private function btnTestArrayCollection_clickHandler(event:MouseEvent):void
            {
                var array:ArrayCollection = new ArrayCollection();
               
                array.addItem(12);
                array.addItem(14);
               
                try {
                    for each(var item:int in array) {
                        log("item: " + item);
                    }
                } catch (e:Error) {
                    log("iteration through ArrayCollection failed: " + e.message);
                    log(e.getStackTrace());
                   
                }
            }

             

            But if I load that very same swf file using:

             

            var appDomain:ApplicationDomain = new ApplicationDomain();
            var ldCtx:LoaderContext = new LoaderContext(false,appDomain);
            ldr.load(new URLRequest("./bin/FlexSample.swf"), ldCtx);
            addChild(ldr);

             

            It crashes with a StackOverflow error:
            Error: Error #1023: Stack overflow occurred.
                at Object$/_hasOwnProperty()
                at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()
                at Object$/_hasOwnProperty()
                at Object/http://adobe.com/AS3/2006/builtin::hasOwnProperty()
                at Object$/_hasOwnProperty()
                ....
                ....

             

            Apparently this is related to the ApplicationDomain the code is running in. If I don't pass a dedicated ApplicationDomain, the code executes just fine.

             

            I'm hunting this bug and I don't know that much about Flash/Flex - but the problems seem to be related.

             

            Maybe it gives you a hint and I would appreciate any hint anyway.

             

            I attached the Test case that can reproduce the behavior reliably.

             

            regards,
            erich

            • 3. Re: Need help diagnosing Stack Overflow error
              emansouri Level 1

              My implementation is somewhat similar.

               

              In my case, the SWF that has the ArrayCollection that is throwing the StackOverflow error is a Flex 4 app that is loaded into a SWFLoader that is attached to a Panel in another Flex 4 app.

               

              The SWFLoader is implemented with the following ApplicationDomain configuration:

               

                              var context:LoaderContext = new LoaderContext();
                              context.securityDomain = SecurityDomain.currentDomain;
                              context.applicationDomain = new ApplicationDomain();
                              _swfLoader.loaderContext = context;

               

              I am hoping someone can shed more light on this as it is a very disruptive problem.  Loading SWFs inside SWFs is going to become more commonplace I believe and it is unacceptable to have to deal with this limitation in using constructs as crucial as the ArrayCollection and ObjectProxy.

              • 4. Re: Need help diagnosing Stack Overflow error
                eburi Level 1

                hi,

                Just found this bug in the Adobe Bug database:

                http://bugs.adobe.com/jira/browse/FP-939?page=com.atlassian.jira.plugin.system.issuetabpan els:all-tabpanel

                 

                Seems to describe what you experience.

                 

                I can't make any sense out of the response yet and I don't think that it helps me a lot...

                 

                - erich

                • 5. Re: Need help diagnosing Stack Overflow error
                  emansouri Level 1

                  Thank you for posting this.  I had stumbled across this before.

                   

                  It makes as much sense to me now as it did then which is that it makes no sense at all.

                   

                  What is particularly troubling is how it seems Adobe has dismissed this as a bug.  I have tried to implement the workaround mentioned but it didn't work.  I guess I need to dig deep into the Proxy class to understand it so I can implement my own workaround.

                  • 6. Re: Need help diagnosing Stack Overflow error
                    Flex harUI Adobe Employee

                    Not sure why it has that status.  A similar bug is now logged against the AVM https://bugzilla.mozilla.org/show_bug.cgi?id=442770

                     

                    The solutions I know of are to share the Proxy-based class from the main applicationdomain or to load the SWF from a different domain.

                     

                    Alex Harui

                    Flex SDK Developer

                    Adobe Systems Inc.

                    Blog: http://blogs.adobe.com/aharui

                    • 7. Re: Need help diagnosing Stack Overflow error
                      emansouri Level 1

                      In my implementation, I am already loading the SWF from a different domain.  The main SWF is at a domain of cerberus.ucompass.com and the child SWF loaded into the SWFLoader is loaded to applications.ucompass.com.  I have very little (pretty much zero) experience working with the Proxy and associated classes and I have looked over some of the examples out there for doing what you suggest but at this point I am not "getting it".

                       

                      Could you please help me with a simple example that I can implement?  This problem is causing havoc for me (I have been trying to solve it for a week) and I would be very grateful if you could help me with some actual examples.

                       

                      Thank you most sincerely in advance.

                      • 8. Re: Need help diagnosing Stack Overflow error
                        Flex harUI Adobe Employee

                        What properties and parameters on your SWFLoader?

                         

                        Alex Harui

                        Flex SDK Developer

                        Adobe Systems Inc.

                        Blog: http://blogs.adobe.com/aharui

                        • 9. Re: Need help diagnosing Stack Overflow error
                          emansouri Level 1

                          Hello,

                           

                          My application will attach a SWFLoader in one of two configurations:

                           

                          Configuration 1:

                           

                          _swfLoader.loadForCompatibility = true;

                           

                          Configuration 2:

                           

                          var context:LoaderContext = new LoaderContext();
                          context.securityDomain = SecurityDomain.currentDomain;
                          context.applicationDomain = new ApplicationDomain();
                          _swfLoader.loaderContext = context;

                           

                          I experience the stack error in both configurations.

                           

                          The child SWFs that are loaded implement a SWC that is also used in the main container that has numerous Singleton which is why I need to implement the child SWF in a new ApplicationDomain.

                           

                          Thank you for your assistance and guidance here.

                          • 10. Re: Need help diagnosing Stack Overflow error
                            Flex harUI Adobe Employee

                            Both configuration are effectively the same and will experience the Proxy bug.  Classes using Proxy must be in the first applicationDomain in a Sandbox.  By using SecurityDomain.currentDomain, you are import loading the SWF as a secondary applicationDomain in the main Sandbox.

                             

                            You can use null for the securityDomain in order to get a new Sandbox, and I think you then can use allowDomain in both SWFs to get back to the security model you are currently using.

                             

                            Alex Harui

                            Flex SDK Developer

                            Adobe Systems Inc.

                            Blog: http://blogs.adobe.com/aharui

                            • 11. Re: Need help diagnosing Stack Overflow error
                              emansouri Level 1

                              I have made the following change to one of my configurations per your recommendation and am continuing to receive the StackOverflow error.

                               

                              i have changed this:

                               

                              _swfLoader.loadForCompatibility = true;

                               

                              to this:

                               

                              var context:LoaderContext = new LoaderContext(false,new ApplicationDomain(ApplicationDomain.currentDomain),null)

                              _swfLoader.loaderContext = context;

                               

                              And the problem still continues.

                               

                              I am hoping you can provide me some further things to try to get a workaround established.

                               

                              Thank you in advance.

                              • 12. Re: Need help diagnosing Stack Overflow error
                                Flex harUI Adobe Employee

                                And that was for a SWF on another domain?  Try not setting a loaderContext at all.  If the SWF is on a different domain/sub-domain it should automatically load into a separate sandbox.

                                 

                                Alex Harui

                                Flex SDK Developer

                                Adobe Systems Inc.

                                Blog: http://blogs.adobe.com/aharui

                                • 13. Re: Need help diagnosing Stack Overflow error
                                  emansouri Level 1

                                  Hello,

                                   

                                  Thank you for your continued assistance.

                                   

                                  Per your recommendation, I tried to set no loaderContext property on the SWFLoader but I still received the StackOverflow error.

                                   

                                  What is so frustrating about this, is it doesn't happen consistently.  I may be able to successfully load the SWF into the SWFLoader 5 or 6 times in row without error, then on the 7th attempt it will give a StackOverflow error.  I have not found any pattern whatsoever in the frequency of its occurrence.

                                   

                                  I do again appreciate any further ideas you have here.

                                  • 14. Re: Need help diagnosing Stack Overflow error
                                    Flex harUI Adobe Employee

                                    Please confirm that the SWF you are loading is hosted on a separate domain/sub-domain than the loading SWF.

                                     

                                    Alex Harui

                                    Flex SDK Developer

                                    Adobe Systems Inc.

                                    Blog: http://blogs.adobe.com/aharui

                                    • 15. Re: Need help diagnosing Stack Overflow error
                                      emansouri Level 1

                                      It definitely is.

                                       

                                      I have a main container that is loaded at the domain of cerberus.ucompass.com and it loads SWFs from other domains.

                                      • 16. Re: Need help diagnosing Stack Overflow error
                                        Flex harUI Adobe Employee

                                        Can you guarantee that no other SWFs are being loaded into secondary applicationDomains?  If you just have those two SWFs, you can still reproduce the error?

                                         

                                        Alex Harui

                                        Flex SDK Developer

                                        Adobe Systems Inc.

                                        Blog: http://blogs.adobe.com/aharui

                                        • 17. Re: Need help diagnosing Stack Overflow error
                                          emansouri Level 1

                                          To expand a bit more on my implementation, I have an invisible SWFLoader (0x0 and visible=false) added to the main container that loads a Flash CS4 application.  This serves as a controller to handle double clicks of graphic artifacts on the container.  The controller in some instances will launch an MDI window (some classes that extend the flexmdi in the flexlib) and onto the MDI Window (technically a panel) will be attached a SWFLoader that will load this Flex 4 application which is what is triggering the StackOverflow as it utilizes ArrayCollections and ObjectProxy.

                                           

                                          I went through and removed all references to creating new application domains in the SWFs that are loaded and am still encountering the StackOverflow.

                                          • 18. Re: Need help diagnosing Stack Overflow error
                                            Flex harUI Adobe Employee

                                            Sounds like there are a minimum of 3 SWFs.  What are the URLs for those SWFs?  What flags and properties are you using on those SWFLoaders?

                                             

                                            I'm done for the evening.  I will check for your response tomorrow.

                                             

                                            Alex Harui

                                            Flex SDK Developer

                                            Adobe Systems Inc.

                                            Blog: http://blogs.adobe.com/aharui

                                            • 19. Re: Need help diagnosing Stack Overflow error
                                              emansouri Level 1

                                              Mr Harui,

                                               

                                              Thank you for your continued follow-up.

                                               

                                              The implementation involves the "main container" that loads the SWFs and also an "application" which is a controller that gets loaded into a 0x0 invisible SWFLoader.  This SWFLoader can be on any URL but will always be a different URL than the main container.

                                               

                                              Then the "application" (that is loaded into the invisible SWF) can "tell" (via a LocalConnection process) the main container to launch a SWFLoader onto an MDIWindow instance or into a SWFLoader anchored onto a VBox at a static position on the main container (I refer to the "application" as the a "Portlet Manager").  These additionally deployed SWFLoaders (I call them "Portlet Applications") will then be loaded to the same domain or a different domain as the "application" (the invisible SWFLoader).  I refer to the continuum of the Portlet Manager the the Portlet Applications it manages as a "Portlet Instance".

                                               

                                              In my implementation, a typical scenario would likely be that the "application" and the SWFs that the application load (are on the same domain

                                               

                                              All this is part of a project I am building that is a Flex/AIR based e-Learning Operating System.

                                               

                                              So that is my scenario.  I have a crucial need to have these SWFs loaded by the main container sandboxed from each other so they can use the same SWC but use their own Singleton and Multiton instances.  I'll add that the SWC has the logic that facilitates the LocalConnection-based communication mechanism that the communication between SWFs is based on.  Also, obviously, this is the only possible communication protocol I can rely on for communication to the AIR application that is associated with this (before the ServerSocket class is available in AIR 2.0 that is).

                                               

                                              The SWFs that I'll be loading into the main container will be UI based implementations and will make extensive use of Flex components and, therefore, can be expected to heavily leverage Proxy-based classes such as the ArrayCollection and ObjectProxy.

                                               

                                              If I don't at least find a workaround for this, I'll need to backtrack significantly which will be, well, disruptive and pretty demoralizing.

                                               

                                              Thank you in advance for your continued leadership and assistance here.  I am predicting the next course of action you are going to recommend is going to be on some form of overridden Proxy class(es) to be implemented?

                                              • 20. Re: Need help diagnosing Stack Overflow error
                                                Flex harUI Adobe Employee

                                                I would recommend a third domain/sub-domain for the portlets.

                                                 

                                                Note that it isn't that a class subclasses Proxy that is the problem, it is whether you call a flash_proxy namespaced method on that class.  For example, with ArrayCollection, you can call methods like getItemAt and createCursor to get the items in the collection, but using [] access is what will cause the error.

                                                 

                                                Therefore, it might be possible for you to avoid the problem by changing code that does things like

                                                 

                                                ac[1] = "foo";

                                                foo = ac[2];

                                                for (var i:int = 0; i < ac.length ; i++)

                                                     foo = ac+

                                                 

                                                with:

                                                ac.setItemAt("foo", 1);

                                                foo = ac.getItemAt(2);

                                                for (var i:int = 0; i < ac.length ; i++)

                                                     foo = getItemAt(i);

                                                 

                                                Alex Harui

                                                Flex SDK Developer

                                                Adobe Systems Inc.

                                                Blog: http://blogs.adobe.com/aharui

                                                • 21. Re: Need help diagnosing Stack Overflow error
                                                  eburi Level 1

                                                  Hi,

                                                   

                                                  does that mean, that the Problems I'm experiencing with ArrayCollections and Bindings under the same circumstances (swf loaded into a dedicated application domain) can all be tracked down to that Bug with Proxies?

                                                  https://bugzilla.mozilla.org/show_bug.cgi?id=442770

                                                   

                                                  I mean:

                                                   

                                                  var array:ArrayCollection = new ArrayCollection();

                                                  ...

                                                  for each(var item:int in array) {
                                                      log("item: " + item);
                                                  }

                                                   

                                                  causes a Stackoverflow, if the swf is loaded with a new ApplicationDomain.

                                                  and:

                                                   

                                                  [Bindable]

                                                  public var bindableString:String;

                                                  ...

                                                  BindingUtils.bindSetter(bindableStringBindSetter, this, "bindableString");

                                                   

                                                  causes a Stackoverflow, if the swf is loaded with a new ApplicationDomain.

                                                   

                                                  If so, I think this is a critical Bug and I wonder how fixing that Bug can be accelerated.

                                                   

                                                  Is it so uncommon to load an swf this way, that noone really seems to care much about that?

                                                   

                                                  regards,

                                                  erich

                                                  • 22. Re: Need help diagnosing Stack Overflow error
                                                    emansouri Level 1

                                                    Mr Harui,

                                                     

                                                    Thank you for your continued follow-up and attention to this matter here.

                                                     

                                                    I have several follow-up comments here, as well as several follow-up questions.

                                                     

                                                    First, based on my implementation, it is impossible to avoid loading multiple SWFs that are on the same domain.

                                                     

                                                    For instance, I have multiple icons on the display of the main container that each represent file volumes.  When a file volume is double clicked on, it launches an MDI window and in that MDI window an application is loaded and each file volume loads the same SWF at the same URL to display the file volume and the two file volumes are differentiated simply by the parameters passed to each SWF.

                                                     

                                                    Also, I had learned long ago the perils of using Array syntax to access ArrayCollections.  I exclusively use the ArrayCollection methods to access the ArrayCollection - to add, access, delete, etc.  I'll add that if I access the ArrayCollection using Array syntax, I immediately get the error in all cases versus sporadically when using the established ArrayCollection access methods.

                                                     

                                                    Another point I wanted to expand on.  I mentioned that I had two different configurations.  Both scenarios load the SWF into SecurityDomain.currentDomain and I understand this is necessary to enable items to be dragged between the SWFs needs to occur in my implementation when the _swfLoader.loadForCompatibility = true is the configuration.

                                                     

                                                    At this point, I have abandoned adding ObjectProxy to the ArrayCollection and am adding Objects.  This is very inconvenient but I can deal with this workaround.

                                                     

                                                    However as indicated, I am also getting sporadic StackOverflow errors in other places.

                                                     

                                                    For instance, I have an overridden dragStartHandler method on an extended AdvancedDataGrid and I get frequent StackOverflow errors when calling this method:

                                                     

                                                    var dropIndex:int = this.calculateDropIndex(event);

                                                     

                                                    where "this" is the extended AdvancedDataGrid, and event is a DragEvent

                                                     

                                                    What other workarounds do you have for me to try?  I simply need to be able to resolve this issue and I cannot afford to backtrack around this issue.

                                                     

                                                    I most appreciate your guidance and leadership here.

                                                    • 23. Re: Need help diagnosing Stack Overflow error
                                                      Flex harUI Adobe Employee

                                                      Yes.  I've pushed them to fix this bug, but it doesn't look like it is going to happen soon.  As customers you should vote on the original FP bug and vote on the bugzilla bug as well.

                                                       

                                                      Unfortunately, we believe there is a workaround involving using separate sandboxes, and that has lowered the priority for fixing this issue.

                                                       

                                                      Alex Harui

                                                      Flex SDK Developer

                                                      Adobe Systems Inc.

                                                      Blog: http://blogs.adobe.com/aharui

                                                      • 24. Re: Need help diagnosing Stack Overflow error
                                                        Flex harUI Adobe Employee

                                                        All that matters is that the child SWFs are in a different sandbox than the main app.  As I understand your configuration, you have a main app that has SWFLoader instances that load other applications that cause this proxy bug.  It doesn't matter so much whether the CS4 controller SWF requested that a child SWF get loaded, what matters is which SWF contains the SWFLoader code that will actually do the load.  I'd bet that if you look at a link-report of the main app, that SWFLoader is in there, so the configuration you should create is that the main App's SWFLoader loads the child SWFs from a different domain.   All the child SWFs can be together on a single domain as long as it is different from the main app.

                                                         

                                                        By default (no additional properties like loadForCompatibility or loaderContext or trustContent), that will cause the main app to load the child SWF into a separate sandbox.  You should then call allowDomain in each SWF to trust the other domain.  In our experience that prevents the proxy bug from occurring and also gives you the same trust topology as having loadForCompatibility=true.

                                                         

                                                        There are still places in the framework that use [] access on ArrayCollection and hitting those code paths will cause the proxy bug if you do not use this sandbox configuration.

                                                         

                                                        Alex Harui

                                                        Flex SDK Developer

                                                        Adobe Systems Inc.

                                                        Blog: http://blogs.adobe.com/aharui

                                                        • 25. Re: Need help diagnosing Stack Overflow error
                                                          emansouri Level 1

                                                          Mr Harui,

                                                           

                                                          Your persistence and patience in exploring this matter with me is greatly appreciated, and, demonstrates your emphasis on customer support and service.

                                                           

                                                          I probably confused things by referencing the Flash CS4 SWF.

                                                           

                                                          To clarify - my main SWF is loaded at cerberus.ucompass.com and ALL child SWFs are loaded to different domains. In fact, it is being setup at the Apache level that the ONLY SWF cerberus.ucompass.com will be able to serve is the main SWF.

                                                           

                                                          Each SWF that is loaded to the main SWF has a SWFLoader that has one of the following two configurations:

                                                           

                                                                      if(!_window.applicationItem.sandbox)
                                                                      {
                                                                          _swfLoader.loadForCompatibility = true;
                                                                      }
                                                                      else
                                                                      {
                                                                          var context:LoaderContext = new LoaderContext();
                                                                          context.securityDomain = SecurityDomain.currentDomain;
                                                                          context.applicationDomain = new ApplicationDomain();
                                                                          _swfLoader.loaderContext = context;
                                                                      }

                                                           

                                                          Also, all SWFs that are loaded, as well as the main SWF, have an SDK that has the following commands executed when the SWF is loaded:

                                                           

                                                          Security.allowDomain('*');
                                                          Security.allowInsecureDomain('*');

                                                           

                                                          I have commented out the SWFLoader settings above but continued to receive the error.

                                                           

                                                          Does the timing or placement of Security.allowDomain('*'); and Security.allowInsecureDomain('*'); have any bearing on this situation?

                                                           

                                                          FYI - as far as my two configurations, I am trying to implement "Sandboxed" and "Non-Sandboxed" configurations for the loaded SWFs.

                                                           

                                                          I want one configuration to be totally Sandboxed, and the other to allow SWFs to be able to allow drag and drops between other non-sandboxed SWFs as well as the main SWF.

                                                           

                                                          I have spent a lot of time researching this matter and a number of the Marshall Plan presentations and papers (some of which I think you authored) and I thought I had finally arrived at a configuration that worked until this Proxy bug started appearing.

                                                           

                                                          I appreciate your continued assistance in helping to find a suitable workaround that I can employ until this bug is fixed that lets me achieve my goals.

                                                          • 26. Re: Need help diagnosing Stack Overflow error
                                                            Flex harUI Adobe Employee

                                                            Use of Proxy in ArrayCollection or elsewhere makes loadForCompatibilty=true unusable because of this proxy bug.  The replacement configuration for loadForCompatibility=true is to place the child applications on a separate domain/sub-domain use default settings and call allowDomain in both SWFs.

                                                             

                                                            Note that calling allowDomain breaks down the walls of the sandbox, so if you really want a security sandbox, you should not make those calls.

                                                             

                                                            Your findings are inconsistent with having set up this configuration correctly.  I would verify that the main SWF is in fact being loaded from http://cerebrus.ucompass.com and the child SWFs are being loaded from somewhere else.  If you are testing your main app from the IDE and loading it from file:// you may not end up in the desired configuration.

                                                             

                                                            You can run a few tests to verify that you are configured correctly.  First, do not call allowDomain and see if you get security errors trying to access the stage from the child SWF.  Second, examine the loaderInfo property on the child application and see if it has the correct settings for sameDomain and parentAllowsChild and childAllowsParent.  Once you prove the sandbox is set up, then see if you still experience the proxy problem, then finally, make the calls to allowDomain and see what your results are.

                                                             

                                                            All of the code you justed posted that configures the _swfLoader should be commented out or deleted, and verify that no properties are set at the time the SWFLoader is instantiated, and verify that your updated SWF did in fact get properly deployed to the correct server and isn't somehow cached in a browser cache somewhere.

                                                             

                                                            Alex Harui

                                                            Flex SDK Developer

                                                            Adobe Systems Inc.

                                                            Blog: http://blogs.adobe.com/aharui

                                                            • 27. Re: Need help diagnosing Stack Overflow error
                                                              emansouri Level 1

                                                              Mr Harui,

                                                               

                                                              Thank you for your continued follow-up.

                                                               

                                                              I have spent the last few hours meticulously following your latest comments and instructions.

                                                               

                                                              I have been unable to correct the problem though I do have some observations that may be useful here.  I'll list them out in no particular order:

                                                               

                                                              * I have commented out all the code that was prescribed for deletion/commenting

                                                               

                                                              * I have my main SWF  configured to debug directly to cerberus.ucompass.com - so when I debug the project, the main app loads to cerberus.ucompass.com.  I have configured /etc/hosts on my machine so that cerberus.ucompass.com resolves to the localhost, and I have set Apache up properly to enable this.  Please comment if this configuration can be problematic.

                                                               

                                                              * My child SWF in question here is a separate Flex project and it is set up to debug directly to applications.ucompass.com which is also resolving to my localhost.  This emulates the production configuration I will implement someday.

                                                               

                                                              * I have insured the SWFs are not being cached and am using trace directives to confirm I am dealing with the proper recompiled SWFs

                                                               

                                                              * My main SWF at cerberus.ucompass.com loads an XML document from applications.ucompass.com well before any SWFs are loaded via SWFLoader.  One warning I have had for a long time and I have largely ignored it as I haven't found any documentation about it can be seen below:

                                                               

                                                              *** Security Sandbox Violation ***
                                                              SecurityDomain 'http://cerberus.ucompass.com/Educator2_beta/bin-debug/Educator2_beta.html?debug=true' tried to access incompatible context 'http://applications.ucompass.com/manifests/dockManifest.xml'

                                                               

                                                              This warning is omnipresent and seems to show up regardless of whatever configuration I have in place and it is repeated many times.  I still do not have a clear understanding of why I am encountering this error and am not sure if it gives you any clues here.

                                                               

                                                              * I removed the Security.allowDomain('*') calls in both child and parent SWFs.  Then in the child SWF, I made a call to:

                                                               

                                                              trace(stage)

                                                               

                                                              and that call was successful which I didn't expect would be the case

                                                               

                                                              * With Security.allowDomain('*') out of the picture, I tested the loaderInfo.parentAllowsChild and loaderInfo.childAllowsParent properties of the child SWF.  Both were false.  I re-added Security.allowDomain('*') calls to the SWC and recompiled the SWFs.  I tested loaderInfo.parentAllowsChild and loaderInfo.childAllowsParent.  I found loaderInfo.parentAllowsChild was true and loaderInfo.childAllowsParent was false.  I then realized that the calls to Security.allowDomain('*') in the SWC are called after the child SWFs have instantiated a Singleton in the SWC which happens after the application/SWF has finished loading and initializing.  I placed the Security.allowDomain('*') calls in the main class of the child SWF outside the constructor.  Then, I found both loaderInfo.parentAllowsChild and loaderInfo.childAllowsParent were true - however the StackOverflow error continues when adding ObjectProxy items to an ArrayCollection and then accessing the ArrayCollection.

                                                               

                                                              Thank you for your patience and continued intervention here.

                                                              • 28. Re: Need help diagnosing Stack Overflow error
                                                                Flex harUI Adobe Employee

                                                                The next test is to go back to the setup where parentAllowsChild=false and childAllowsParent=false and see if the Proxy error happens in that configuration.  In this configuration, you should see lots of security warnings in the console about the child SWF trying to access the parent SWF and vice versa.  As long as you see that, any mappings your doing for domains is probably ok.

                                                                 

                                                                Security warnings in the console can be ignored unless they cause an exception dialog to show up.

                                                                 

                                                                trace(stage) won't throw an error.  stage.addEventListener should.

                                                                 

                                                                You might also try creating another very simple test pair of applications where the child SWF use proxy.  Load the child with loadForCompatibility, prove you get the error, then try loading it from another domain and see if the error goes away.

                                                                 

                                                                 

                                                                Alex Harui

                                                                Flex SDK Developer

                                                                Adobe Systems Inc.

                                                                Blog: http://blogs.adobe.com/aharui

                                                                • 29. Re: Need help diagnosing Stack Overflow error
                                                                  emansouri Level 1

                                                                  Mr Harui,

                                                                   

                                                                  Thank you for your continued follow-up.

                                                                   

                                                                  I have just spent the last few hours implementing your prescribed suggestions and I think I am even more perplexed now then I was when I opened this thread.

                                                                   

                                                                  In summary:

                                                                   

                                                                  * I made adjustments so that parentAllowsChild = false and childAllowsParent = false in the child SWF, and this made no bearing on the outcome - I continued to receive the error.

                                                                   

                                                                  * As predicted, I do indeed get an error on stage.addEventListener in the child when parentAllowsChild = false and childAllowsParent = false

                                                                   

                                                                  * I created two completely new Flex projects - ParentSWF and ChildSWF and tried to emulate the exact setup in my main implementation.  I tried to add more and more features until I got to the point where the StackOverflow error occurred.  Frustratingly, and as has been typical throughout this whole situation, I was not able to reproduce the StackOverflow.  I loaded the child SWF with and without loadForCompatibility = true.

                                                                   

                                                                  * Another detail, in both my child and parent SWFs, I am making a call similar to the following:

                                                                   

                                                                  var event:IEventDispatcher = StyleManager.loadStyleDeclarations(FILE_MANAGER_WINDOW_STYLESHEET,true,true,ApplicationDo main.currentDomain,SecurityDomain.currentDomain);          

                                                                  where FILE_MANAGER_WINDOW_STYLESHEET will be on a domain of applications.ucompass.com in the child SWF and the stylesheet  is loaded from the cerberus.ucompass.com in the parent SWF.

                                                                   

                                                                  I emulated this circumstance in my prototype test parent/child but it doesn't seem to be related to the problem.

                                                                   

                                                                  I am pretty much stuck in the mud here but will continue trying differerent ideas and suggestions until I figure this out.

                                                                  • 30. Re: Need help diagnosing Stack Overflow error
                                                                    emansouri Level 1

                                                                    Mr Harui,

                                                                     

                                                                    I have a very strange observation to report here.

                                                                     

                                                                    Please bear with me, there is no way around going into some of the complex details of the implementation in discussion here.

                                                                     

                                                                    The particular feature I am building that is causing me all this trouble is a File Manager apparatus.

                                                                     

                                                                    I am going to provide a list of details below, some of which I have already covered, and I apologize for the redundancy and I have also attached a screen capture to the post to perhaps give a better visual understanding of what I am doing:

                                                                     

                                                                    * The main SWF is a Flex 3 application loaded at cerberus.ucompass.com, and all other SWFs loaded are currently loaded from a domain of applications.ucompass.com

                                                                     

                                                                    * The main SWF has graphic icons attached to its stage that represent file volumes.  These file volumes represent file volumes on the local user's hard drive, or, file volumes on remote file systems (FTP, WebDAV, etc.).

                                                                     

                                                                    * When the graphic icons are double clicked, it launches an MDI window and inside that MDI window, a child SWF is loaded via the SWFLoader.

                                                                     

                                                                    * The child SWF is a Flex application that has an AdvancedDataGrid implementation that lets the user browse/manage the files in the associated file volume.

                                                                     

                                                                    * Regardless of the type of file volume, the SWF that opens up in the MDI window is the same SWF and different parameters are passed to it that are read in the loaderInfo.parameters property.

                                                                     

                                                                    * The child SWF loaded into the MDI window then behaves polymorphically and depending on what type of file volume is being accessed, it retrieves the file information based on an implementation-specific process.  For instance, for local file system volumes, it retrieves the file info via LocalConnection (and now ServerSocket in the AIR 2.0 implementation) from an augmentative AIR application.  For FTP file volumes, it uses a different socket based implementation, etc.

                                                                     

                                                                    * Here is where it gets very strange - so I am passing parameters to the child SWF - the file viewer - whenever one of the parameters has a string that looks like a network address - like some.domain.com or user@domain.com, the behavior of the child SWF is different - it is as if it is disconnected from the debugger - and trace statements do not work.  Further, the ability to drag and drop between SWFs does not work.  I have gotten around this hassle by making the following substitution in the parameters that are sent to the child SWF:

                                                                     

                                                                                    var pattern1:RegExp = /\./g;
                                                                                    str = str.replace(pattern1,"_PERIOD_");
                                                                                    var pattern2:RegExp = /\@/g;
                                                                                    str = str.replace(pattern2,"_ATSIGN_");

                                                                     

                                                                    and then in the child SWF, I reverse this:

                                                                     

                                                                                var pattern1:RegExp = /\_ATSIGN\_/g;
                                                                                value = value.replace(pattern1,"@");
                                                                                var pattern2:RegExp = /\_PERIOD\_/g;
                                                                                value = value.replace(pattern2,".");

                                                                     

                                                                    * What I have just learned is that, so far, the StackOverflow errors are NOT occurring in file volumes where the data about the files comes from the augmentation AIR application.  They are only occurring in file volumes where the data about the files is coming from a remote retrieval.  I have further tried to explore this and have turned off the remote retrieval process in these instances and tried manually building the data source and the StackOverflow continues.

                                                                     

                                                                    Does this make any sense at all?  It appears that with the problems encountered adding ObjectProxy to ArrayCollection, something about the source of the objects being cast into ObjectProxy, or something about the behavior of the SWF established by the parameters passed to the SWF is contributing to this problem.

                                                                     

                                                                    I look forward to any analysis or theories you have of this increasingly peculiar situation.

                                                                    • 31. Re: Need help diagnosing Stack Overflow error
                                                                      eburi Level 1

                                                                      Hi,

                                                                       

                                                                      I've been following this Thread for a while now and I can't really keep up wih the Proxy-Problem at the core of it.

                                                                       

                                                                      Maybe I should start a new Thread to isolate this Proxy-Problem and to discuss solutions/workaround. Or is there an other place that covers that already? Should we discuss this through comments on the FP-Bug?

                                                                       

                                                                      Because so far, I was not able to understand the possible workarounds.

                                                                       

                                                                      What I want is this:

                                                                       

                                                                      AppDomain1                 

                                                                      ----------------------     

                                                                      |   <MainAppLoader>  |        AppDomain2

                                                                      |                    |        ---------------------------------

                                                                      |Loader  ============|========|=> <FlexSample>                |

                                                                      ----------------------        ---------------------------------

                                                                       

                                                                      But, i run into the Proxy Problem (or hasOwnProperty-Endless-Recursion-Stackoverflow) that prevents me from using ArrayCollection or Bindings and potentially other stuff in the  <FlexSample>-Application.

                                                                       

                                                                      Then Mr Harui wrotes:

                                                                       

                                                                      Unfortunately, we believe there is a workaround involving using separate sandboxes, and that has lowered the priority for fixing this issue.

                                                                       

                                                                      and

                                                                       

                                                                      All that matters is that the child SWFs are in a different sandbox than the main app.  As I understand your configuration, you have a main app that has SWFLoader instances that load other applications that cause this proxy bug.  It doesn't matter so much whether the CS4 controller SWF requested that a child SWF get loaded, what matters is which SWF contains the SWFLoader code that will actually do the load.  I'd bet that if you look at a link-report of the main app, that SWFLoader is in there, so the configuration you should create is that the main App's SWFLoader loads the child SWFs from a different domain.   All the child SWFs can be together on a single domain as long as it is different from the main app.

                                                                       

                                                                      So I tried this setup with an intermediate FlexLoader.swf that simply loads the FlexSample in the same ApplicationDomain. But the MainAppLoader now loader the FlexLoader.swf into a new ApplicationDomain.

                                                                       

                                                                      AppDomain1                 

                                                                      ----------------------     

                                                                      |   <MainAppLoader>  |        AppDomain2

                                                                      |                    |        ---------------------------------

                                                                      |Loader  ============|========|=> <FlexLoader>                |

                                                                      ----------------------        |   Loader ======> <FlexSample> |

                                                                                                    ---------------------------------

                                                                      But, well, no luck - crashes again! I tried writting the intermediate Loader <FlexLoader> in Flex using SWFLoader and in the Flash IDE creating a simple SwfLoader.fla that uses flash.display.Loader.

                                                                       

                                                                      So, I like to know what the workaround is or how I'm supposed to create different sandboxes and to Load the SWF in there.

                                                                       

                                                                      I attached the file FlashFlexIssueProject.zip that contains all the code and examples. If it helps, I can further work on creating a very simple Testcase to demonstrate the problem.

                                                                       

                                                                      But what I'm looking for is a piece of code that simply shows how I'm supposed to load that swf in a way that this Problem doesn't show up.

                                                                       

                                                                      I realize that there is a lot of talk going on here about domains and I get confused about whether we're talking about ApplicationDomains or network domains. If the workaround is to load the swf from different network locations, it's of no use for me as I'm loading the swf from the filesystem and I can't possibly change that.

                                                                       

                                                                      regards,

                                                                      erich

                                                                      • 32. Re: Need help diagnosing Stack Overflow error
                                                                        Flex harUI Adobe Employee

                                                                        You need two domains/sub-domains like www.adobe.com and childApps.adobe.com

                                                                         

                                                                        Put the main app on www.adobe.com and load the child app from childApps.adobe.com.  Use the default settings for SWFLoader.  The result should be that the child app goes into its own sandbox and the proxy problem should go away.

                                                                         

                                                                        If you need to communicate between the main and child apps, each app should call allowDomain to permit access from the other app.

                                                                         

                                                                        Alex Harui

                                                                        Flex SDK Developer

                                                                        Adobe Systems Inc.

                                                                        Blog: http://blogs.adobe.com/aharui

                                                                        • 33. Re: Need help diagnosing Stack Overflow error
                                                                          emansouri Level 1

                                                                          Mr eburi,

                                                                           

                                                                          I apologize for monopolizing this thread with details of my very specific implementation issue.

                                                                           

                                                                          I have been studying all the various matters in discussion here relating to ApplicationDomains, LoaderContexts, SecurityDomains, and how they relate to Proxies and classes that extend Proxy (like ArrayCollection), and, to be honest, I am still very fuzzy on the topic.

                                                                           

                                                                          There is a concept known as the "Marshall Plan", and here is a link to an article about it:

                                                                           

                                                                          http://opensource.adobe.com/wiki/display/flexsdk/Marshall+Plan

                                                                           

                                                                          That article and others you should easily be able to find on Google were somewhat helpful to me in understanding the different configurations that can exist for loading SWFs into other SWFs but, again, this is an area I am still struggling with.

                                                                           

                                                                          As far as the problem I've been talking about here, finally, after much agonizing study and effort, I was able to resolve the issue.

                                                                           

                                                                          This will be the last posting I make on this thread due to the length and complexity this thread has grown to.

                                                                           

                                                                          As far as my problem, I have resolved it and can now use ArrayCollection and ObjectProxy where I was otherwise getting StackOverflows.  I know how I resolved it but I don't know why my resolution works.

                                                                           

                                                                          Maybe Mr Harui can elaborate for us.

                                                                           

                                                                          What was going on, I have a method I call on my main SWF that attaches an icon to an MDI window.  MDI extends Panel, so this is essentially adding an icon to the titleIcon property of a Panel container.

                                                                           

                                                                          There are two different kinds of parameters that can be sent to this method, a ByteArray, or a string.

                                                                           

                                                                          The titleIcon property of a Panel expects the icon to be a Class instance of an image, which be compiled into the SWF.

                                                                           

                                                                          However, in my case, that does me no good as the icons to be placed on the MDI Window are dynamic and their source will be a ByteArray retrieved from AIR, or a static URL to an image elsewhere on the web.

                                                                           

                                                                          Depending on the input parameter, I either convert the ByteArray to a class instance, or, I retrieve the image at its URL, decode it into a ByteArray, then convert it to a class instance.

                                                                           

                                                                          Now in that second option, where I convert the image to a ByteArray by obtaining the source of the image at its URL, I use a Loader instance.

                                                                           

                                                                          This was my code initially to retrieve the image:

                                                                           

                                                                          loader.load(new URLRequest(source as String));

                                                                           

                                                                          This is what I changed the code to that resolved my issue:

                                                                           

                                                                          loader.load(new URLRequest(source as String), new LoaderContext(false,ApplicationDomain.currentDomain,SecurityDomain.currentDomain));

                                                                           

                                                                          In the File Manager I was describing earlier, when the file volume being accessed is a Desktop volume, then AIR will provide the app with a ByteArray, otherwise, in all other cases, the image is supplied by a static URL.

                                                                           

                                                                          This is why I was not encountering the problem with the desktop volumes and only remote volumes.

                                                                           

                                                                          So the moral of the story here, it turned out that a process that didn't even relate to loading SWFs but related to loading an image was impacting my ability to use ArrayCollection and ObjectProxy.

                                                                           

                                                                          I do hope Mr Harui can shed some light on this further to help explain this as I have a feeling I will encounter this sort of problem again somewhere.

                                                                          • 34. Re: Need help diagnosing Stack Overflow error
                                                                            Flex harUI Adobe Employee

                                                                            I'm glad you resolved your issue.  It appears that loading images (were they PNGs, JPGs, or GIFs and not SWFs?) sets up secondary application domains or a configuration that is equivalent.  None of our testing has explored that area.  We do know that use of ByteArray exercises a similar part of the player's type conversion mappings that is known to fail with secondary application domains.

                                                                             

                                                                            Your changes are now loading the images into the primary application domain.  Note that the images may not fully unload in this configuration.

                                                                             

                                                                            Hopefully you can continue forward and be successful with your application.

                                                                             

                                                                            Alex Harui

                                                                            Flex SDK Developer

                                                                            Adobe Systems Inc.

                                                                            Blog: http://blogs.adobe.com/aharui

                                                                            • 35. Re: Need help diagnosing Stack Overflow error
                                                                              emansouri Level 1

                                                                              Mr Harui,

                                                                               

                                                                              Indeed - I am delighted.  I am most looking forward to moving on from this hurdle to bigger and better things.

                                                                               

                                                                              To follow up here, the source of the images in this case are GIFs, JPGs, or PNGs and not SWFs.

                                                                               

                                                                              In my class that encodes the ByteArray into a Class instance, I actually am drawing out the contents of the ByteArray onto a BitmapAsset's bitmapData property.

                                                                               

                                                                              The class extends BitmapAsset and here is a chunk of the pertinent code:

                                                                               

                                                                              bitmapData = new BitmapData(18,18, true, 0x00FFFFFF);

                                                                              bitmapData.draw(loader, new Matrix(bitmapData.width/loader.width, 0, 0, bitmapData.height/loader.height, 0, 0));

                                                                               

                                                                              where loader is the Loader that is used to retrieve the image.

                                                                               

                                                                              Since Loader implements IBitMapDrawable, and the first argument to BitmapData.draw() needs to be an IBitMapDrawable instance, this technique works out well as I was pleasantly surprised to discover.

                                                                               

                                                                              Thanks again for all your attention and help on this case.

                                                                               

                                                                              I am sure you'll be hearing from me again in other threads.

                                                                              • 36. Re: Need help diagnosing Stack Overflow error
                                                                                eburi Level 1

                                                                                hi,

                                                                                 

                                                                                I'm glad you found a solution to your problem. Although I can't see, what really changed in your code now, because I thought,

                                                                                 

                                                                                loader.load(new URLRequest(source as String));

                                                                                 

                                                                                and

                                                                                loader.load(new URLRequest(source as String), new LoaderContext(false,ApplicationDomain.currentDomain,SecurityDomain.currentDomain));

                                                                                 

                                                                                is the same, as applicationDomain, if not set, defaults to ApplicationDomain.currentDomain. Same for the SecurityDomain.



                                                                                Anyway, I'm still stuck with this bug and the described workaround - loade from different (network-)domain - is just no option for me, because I pointed out that my swfs are not loaded from the network at all.

                                                                                 

                                                                                The loaded swf's are from 3rd-Parties which is why I can't control/trust them and therefor want to load them into a separate ApplicationDomain. But, they are downloaded at one point and later loaded from the disk.

                                                                                 

                                                                                Mr Harui, can you confirm, that there is no workaround if I'm loading the swf's from a local source (file:///.../test.swf).

                                                                                 

                                                                                best regards,

                                                                                erich

                                                                                • 37. Re: Need help diagnosing Stack Overflow error
                                                                                  Flex harUI Adobe Employee

                                                                                  If you don't specify SecurityDOmain.currentDomain and the content is from another domain, it will get loaded into its own sandbox, which is the goal of the workaround.

                                                                                   

                                                                                  Alex Harui

                                                                                  Flex SDK Developer

                                                                                  Adobe Systems Inc.

                                                                                  Blog: http://blogs.adobe.com/aharui

                                                                                  • 38. Re: Need help diagnosing Stack Overflow error
                                                                                    eburi Level 1

                                                                                    Mr Harui,

                                                                                     

                                                                                    can you confirm, that ther is no known workaround for the Proxy-issue in case, that the loading-swf and the loaded-swf are run/loaded directly from the filesystem. which is, what happens in my setup and it's not possible to change that as we're talking about a solution that is not web-based.

                                                                                     

                                                                                    - erich

                                                                                    • 39. Re: Need help diagnosing Stack Overflow error
                                                                                      Flex harUI Adobe Employee

                                                                                      If you put the loaded-swf outside the trust boundary, it should force the loaded-swf into its own sandbox, which should be a valid workaround for the Proxy issue.

                                                                                       

                                                                                      For AIR apps, putting the SWF anywhere outside the application directory should be good enough.  Note that means that the loaded-swf cannot access Native and Desktop functionality directly from the SWF.  It will have to marshall communications to the loading-swf for such services.

                                                                                       

                                                                                      Alex Harui

                                                                                      Flex SDK Developer

                                                                                      Adobe Systems Inc.

                                                                                      Blog: http://blogs.adobe.com/aharui

                                                                                      1 2 Previous Next