4 Replies Latest reply on Oct 30, 2011 10:16 PM by neltylhk

    Module Loader inconsistency

    mdanrel Level 1

      Hi there.  I had resolved my Module loader issue. Or so I thought...   I'm seeing a LOT of inconsistency in the behavior while debugging. 

       

      The same code ( untouched ) will at times load the desired module but return sating child is null.  Other times it will return a child property value

      set to the loaded module

       

      In both cases I wait for the Module READY event before trying to read the property.  I'd say 30% of the time it shows this behavior. 

       

      Is it something wrong in my assumption on the READY event or is it really this unpredictable when loading/unloading modules.  I'm concerned that in production it will behave the same way and this would be unacceptable.

        • 1. Re: Module Loader inconsistency
          Flex harUI Adobe Employee

          In general, modules work consistently.  Inconsistent behavior has been linked to timing issues (like when you didn't wait for ready event), memory management issues such as not keeping a strong reference to the module, application domain issues (if you accidentally link all the classes in the module into the main app, the module may not load), and errors in developer code (not loading the right module, module out of sync with main app, mixing SDK versions, etc).

           

          Once we figure out what is going on, you'll get the reliability you're looking for.  I would set a breakpoint in ModuleLoader.moduleReadyHandler and see what happens when you get null for the child.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

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

          • 2. Re: Module Loader inconsistency
            mdanrel Level 1

            Thanks for the suggestion.  Actually I revisited the event handler and modified the Adobe example.

             

            In the Adobe example it's done as follows

             

                var ichild:* = customLoader.child as IModuleInterface;

             

               

                 if ( customLoader.child != null ) {

                      ichild.setUser( currUser );

                    }

             

            I went ahead and changed this to

             

                var ichild:userModule = customLoader.child as userModule


                 if ( customLoader.child != null ) {

                      ichild.setUser( currUser );

                 }

             

             

            This seems to work 100% now. I'm not sure if that's what you meant by strong reference to the module, or whether this is

            a correct approach.

            • 3. Re: Module Loader inconsistency
              Flex harUI Adobe Employee

              No, the way you got it to work is "incorrect".  By referencing the actual class instead of its interface, you've linked the entire class into the main SWF defeating the point of the module.  Interfaces are smaller so linking them into the main SWF doesn't matter as much.

               

              We still don't know what is wrong with your test case.  It will probably require debugging into the moduleloader code to find out why.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

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

              • 4. Re: Module Loader inconsistency
                neltylhk

                I got this problem before. When I changed the module into "Optimize For none" (project->properties->Flex Modules), the problem was solved.