8 Replies Latest reply on Oct 10, 2011 8:42 AM by Darrell Loverin

    Maybe, identified an issue when specified parent domain for RSLs

    Romain Gi. Level 1

      Hi all,

      According to the documentation we have tried to setup the runtime-shared-library-path option to: parent.

      doc: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf674ba-7fff.html#WS19 f279b149e7481c-64f4fc4712daa436650-7fff

      «

      • parent — Loads the RSL into the application domain of the parent application or module.

      »

       

      But in our use case it does not work. Let me explain our use case:

      An Application load a Module with name ParentModule and this parent Module will load 2 Modules: ChildModule1 and ChildModule2.

      The 2 children modules share a common RSL in parent mode: <application-domain-target>top-level</application-domain-target>

       

      The expected result is:

      The ParentModule should load the RSL only one times but at the end the RSL is loaded twice. We can check it in the parentModuleInfo.factory.preloadedRSLs() which should contain 1 entry but contains 2.

       

      The following code can help you to reproduce the issue:

       

      Main.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                       xmlns:s="library://ns.adobe.com/flex/spark" 
                                       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="creationCompleteHandler(event)">
                <fx:Script>
                          <![CDATA[
                                    import mx.events.FlexEvent;
                                    import mx.events.ModuleEvent;
                                    import mx.modules.IModuleInfo;
                                    import mx.modules.ModuleManager;
        
                                    import spark.modules.Module;
        
                                    private var moduleInfo:IModuleInfo;
      
      
                                    protected function creationCompleteHandler(event:FlexEvent):void
                                    {
                                              addEventListener("EndModule1", refreshProblemLabel);
                                              addEventListener("EndModule2", refreshProblemLabel);
                                              moduleInfo=ModuleManager.getModule("../../ParentModule/bin-debug/ParentModule.swf")          ;
                                              moduleInfo.addEventListener(ModuleEvent.READY, moduleReady);
                                              moduleInfo.addEventListener(ModuleEvent.ERROR, moduleError);
                                              moduleInfo.load(new ApplicationDomain(ApplicationDomain.currentDomain),null,null,moduleFactory);
                                    }
        
                                    private function moduleReady(e:ModuleEvent):void
                                    {
                                              var module:Module= e.module.factory.create() as Module;
                                              trace("Parent Module ready");
                                              modContainer.addElement(module);
                                    }
        
                                    private function moduleError(e:ModuleEvent):void
                                    {
                                              trace("Module load error");
                                    }
        
                                    private function getSize(myDictionary:Dictionary):int 
                                    {
                                              var n:int = 0;
                                              for (var key:* in myDictionary) {
                                                        n++;
                                              }
                                              return n;
                                    }
        
                                    private function refreshProblemLabel(event:Event):void
                                    {
                                              problemLabel.text = "Nb loaded RSL in the parent module: " + getSize(moduleInfo.factory.preloadedRSLs) + " Should be equal to 1!" ;
                                    }
        
                          ]]>
                </fx:Script>
                <s:layout>
                          <s:VerticalLayout/>
                </s:layout>
                <s:BorderContainer width="300" height="200" id="modContainer" borderVisible="true" borderStyle="solid" borderColor="red"/>
                <s:Label id="problemLabel" />
      </s:Application>
      

       

      ParentModule.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
                            xmlns:s="library://ns.adobe.com/flex/spark"
                            xmlns:mx="library://ns.adobe.com/flex/mx"
                            minWidth="955" minHeight="600" creationComplete="creationCompleteHandler(event)">
                <fx:Script>
                          <![CDATA[
                                    import mx.events.FlexEvent;
                                    import mx.events.ModuleEvent;
                                    import mx.modules.IModuleInfo;
                                    import mx.modules.ModuleManager;
        
                                    import spark.modules.Module;
        
                                    private var moduleInfo1:IModuleInfo;
                                    private var moduleInfo2:IModuleInfo
        
        
                                    private function loadModule1():void
                                    {
                                              moduleInfo1=ModuleManager.getModule("../../ChildModule/bin-debug/Module1.swf")          ;
                                              moduleInfo1.addEventListener(ModuleEvent.READY, module1Ready);
                                              moduleInfo1.addEventListener(ModuleEvent.ERROR, moduleError);
                                              var applicationDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
                                              moduleInfo1.load(applicationDomain, null, null, moduleFactory);
                                    }
        
                                    private function module1Ready(e:ModuleEvent):void
                                    {
                                              var module:Module= e.module.factory.create() as Module;
                                              trace("Module1 ready");
                                              modContainer.addElement(module);
        
                                    }
                                    private function module2Ready(e:ModuleEvent):void
                                    {
                                              var module:Module= e.module.factory.create() as Module;
                                              trace("Module2 ready");
                                              modContainer.addElement(module);
                                    }
        
                                    private function moduleError(e:ModuleEvent):void
                                    {
                                              trace("Module load error");
                                    }
        
                                    protected function loadModule2():void
                                    {
                                              moduleInfo2=ModuleManager.getModule("../../ChildModule/bin-debug/Module2.swf")          ;
                                              moduleInfo2.addEventListener(ModuleEvent.READY, module2Ready);
                                              moduleInfo2.addEventListener(ModuleEvent.ERROR, moduleError);
                                              var applicationDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
                                              moduleInfo2.load(applicationDomain, null, null, moduleFactory);
                                    }
        
                                    private function creationCompleteHandler(event:FlexEvent):void
                                    {
                                              loadModule1();
                                              loadModule2();
                                    }
        
        
                          ]]>
                </fx:Script>
                <s:layout>
                          <s:VerticalLayout/>
                </s:layout>
                <mx:VBox id="modContainer" width="300" height="200" borderColor="red"
                                                           borderStyle="solid" borderVisible="true"/>
      </s:Module>
      
      

       

      Module1.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="creationCompleteHandler(event)">
                <fx:Script>
                          <![CDATA[
                                    import mx.events.FlexEvent;
        
                                    import pckg.MyClass;
                                    {MyClass}
        
                                    protected function creationCompleteHandler(event:FlexEvent):void
                                    {
                                              var endEvent:Event = new Event("EndModule1",true);
                                              dispatchEvent(endEvent); 
                                    }
        
                          ]]>
                </fx:Script>
        
                <s:Label text="Module1"/>
      </s:Module>
      
      

       

      Module2.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="creationCompleteHandler(event)">
                <fx:Script>
                          <![CDATA[
                                    import mx.events.FlexEvent;
        
                                    import pckg.MyClass;
                                    {MyClass}
        
                                    protected function creationCompleteHandler(event:FlexEvent):void
                                    {
                                              var endEvent:Event = new Event("EndModule2",true);
                                              dispatchEvent(endEvent); 
                                    }
        
                          ]]>
                </fx:Script>
        
                <s:Label text="Module2"/>
      </s:Module>
      
      

       

      The shared RSL class:

       

      MyClass.as:

      package pckg
      {
                public class MyClass
                {
        
                          public function MyClass()
                          {
                          }
        
                }
      }
      
      

       

      Regards,

       

      Romain.

       

      PS: My appology for my poor english level.

        • 1. Re: Maybe, identified an issue when specified parent domain for RSLs
          Darrell Loverin Level 4

          What happens if you wait for module1 to finish loading before you load module2. Maybe when module2 is loading, the RSL has not been loaded yet causing module2 to load the RSL again.

           

           

           

          -Darrell

          • 2. Re: Maybe, identified an issue when specified parent domain for RSLs
            Romain Gi. Level 1

            Hi Darrell,

            In our application we are waiting but not in the sample then I will modify the sample and comeback to you

             

            Cheers,

             

            Romain.

            • 3. Re: Maybe, identified an issue when specified parent domain for RSLs
              Romain Gi. Level 1

              Hi Darrell,

              Then we have modified the sample to wait the first child module ready event and then load the second one. And the result is the same. The issue is not associated to a race condition.

               

              Cheers,

               

              Romain

               

              PS: the new ParentModule code:

               

              <?xml version="1.0" encoding="utf-8"?>

              <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"

                                    xmlns:s="library://ns.adobe.com/flex/spark"

                                    xmlns:mx="library://ns.adobe.com/flex/mx"

                                    minWidth="955" minHeight="600" creationComplete="creationCompleteHandler(event)">

                        <fx:Script>

                                  <![CDATA[

                                            import mx.events.FlexEvent;

                                            import mx.events.ModuleEvent;

                                            import mx.modules.IModuleInfo;

                                            import mx.modules.ModuleManager;

               

                                            import spark.modules.Module;

               

                                            private var moduleInfo1:IModuleInfo;

                                            private var moduleInfo2:IModuleInfo

               

               

                                            private function loadModule1():void

                                            {

                                                      moduleInfo1=ModuleManager.getModule("../../ChildModule/bin-debug/Modu le1.swf")          ;

                                                      moduleInfo1.addEventListener(ModuleEvent.READY, module1Ready);

                                                      moduleInfo1.addEventListener(ModuleEvent.ERROR, moduleError);

                                                      var applicationDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

                                                      moduleInfo1.load(applicationDomain, null, null, moduleFactory);

                                            }

               

                                            private function module1Ready(e:ModuleEvent):void

                                            {

                                                      var module:Module= e.module.factory.create() as Module;

                                                      trace("Module1 ready");

                                                      modContainer.addElement(module);

               

                                                      // load module 2 after module 1 loading

                                                      loadModule2();

               

                                            }

                                            private function module2Ready(e:ModuleEvent):void

                                            {

                                                      var module:Module= e.module.factory.create() as Module;

                                                      trace("Module2 ready");

                                                      modContainer.addElement(module);

                                            }

               

                                            private function moduleError(e:ModuleEvent):void

                                            {

                                                      trace("Module load error");

                                            }

               

                                            protected function loadModule2():void

                                            {

                                                      moduleInfo2=ModuleManager.getModule("../../ChildModule/bin-debug/Modu le2.swf")          ;

                                                      moduleInfo2.addEventListener(ModuleEvent.READY, module2Ready);

                                                      moduleInfo2.addEventListener(ModuleEvent.ERROR, moduleError);

                                                      var applicationDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

                                                      moduleInfo2.load(applicationDomain, null, null, moduleFactory);

                                            }

               

                                            private function creationCompleteHandler(event:FlexEvent):void

                                            {

                                                      loadModule1();

                                            }

               

               

                                  ]]>

                        </fx:Script>

                        <s:layout>

                                  <s:VerticalLayout/>

                        </s:layout>

                        <mx:VBox id="modContainer" width="300" height="200" borderColor="red"

                                                                   borderStyle="solid" borderVisible="true"/>

              </s:Module>

              • 4. Re: Maybe, identified an issue when specified parent domain for RSLs
                Darrell Loverin Level 4

                To reproduce the issue I'll need to know how you compiled the application and modules. Could you provoide the command lines that you used as well as the contents of any configuration files? If you used Flash Builder to compile the project could you describe the application domain settings of the application and modules (do they share the same project).

                 

                Your question seems to be about the "parent" application domain setting but you are specifying "top-level" application domain (application-domain-target>top-level</application-domain-target>). Could you clear up how you are compiling your applications and modules.

                 

                Thanks,

                 

                 

                -Darrell

                • 5. Re: Maybe, identified an issue when specified parent domain for RSLs
                  Romain Gi. Level 1

                  Hi Darrell,

                  First of all I have done a mistake (copy/paste issue  ) we are using "parent" application-domain-target and not top-level. I'm sorry for that.

                  Our sample has been build by FlashBuilder 4.5.1. The project structure is the following:

                   

                  +- flex-rsl                              //<- the root workspace folder

                      +- ChildModule                  //<- child application module project

                          +- src

                              +- Module1.mxml

                              +- Module2.mxml

                      +- Lib                               //<- sharedlib rsl project

                          +- src

                              +- pckg

                                  +- MyClass.as

                      +- Main                            //<- main application project

                          +- src

                              +- Main.mxml

                      +- ParentModule               //<- Parent Module project

                          +- src

                              +- ParentModule.mxml

                   

                  Then the dependencies and configuration options:

                  ChildModule:

                  Flex 4.5.1

                  Libs link Type: External

                  lib:

                    - Source attachement: \Lib\src

                    - Link Type: Runtime shared library (RSL)

                    - RSL URL: Lib.swf

                    - force load RSL: false

                  - Application Domain: parent

                   

                  Lib:

                  Flex 4.5.1

                   

                  ParentModule:

                  Flex 4.5.1

                  Libs link Type: External

                   

                  Main:

                  Flex 4.5.1

                  Libs link Type: External

                   

                  That's all I think.

                  But if you want I can share my sample with you? I don't know how?

                   

                  Thanks,

                   

                  Romain

                   

                  PS: If you want I can open a bug and provide you my sample in attachement

                  • 6. Re: Maybe, identified an issue when specified parent domain for RSLs
                    Darrell Loverin Level 4

                    I could reproduce the problem and found a fix. The bug is written up as https://bugs.adobe.com/jira/browse/SDK-31808. Please see the bug for a possible work around and a patch file. Please vote for the fix.

                     

                     

                    -Darrell

                    • 7. Re: Maybe, identified an issue when specified parent domain for RSLs
                      Romain Gi. Level 1

                      Hi Darrell,

                      What do you think about the following patch:

                      C:\sandbox\open-sources\flex\flex-sdk-mpl-4.5.1.21328-1\frameworks>diff c:\sandbox\open-sources\flex\flex_sdk_4.5.0.2096

                      7_mpl\frameworks\projects\framework\src\mx\utils\LoaderUtil.as c:\sandbox\open-sources\flex\flex-sdk-mpl-4.5.1.21328-1\f

                      rameworks\projects\framework\src\mx\utils\LoaderUtil.as

                      495,497c495,500

                      <             // If there is no parent, ignore the target and load into the current

                      <             // app domain.

                      <             targetModuleFactory = parentModuleFactory;

                      ---

                      >               if (currentModuleFactory == parentModuleFactory)

                      >               {

                      >                 // If there is no parent, ignore the target and load into the current

                      >                 // app domain.

                      >                 targetModuleFactory = parentModuleFactory;

                      >               }

                       

                      Thanks,

                       

                      Romain

                       

                      PS: Thank you for your help.

                      • 8. Re: Maybe, identified an issue when specified parent domain for RSLs
                        Darrell Loverin Level 4

                        I'm not sure about your patch. I attached a patch file to SDK-31808. Please use that patch.