So, the classic 'mistake' was to do this:

 

private function loadModule(url:String):void

{

            var modInfo:IModuleInfo = ModuleManager.getModule(url);

            modInfo.addEventListener(ModuleEvent.READY, readyHandler)

            modInfo.load();

}

 

This worked in 2.0.1 because there was a memory leak.  We fixed the leak
in Flex 3 and suddenly, this scenario could cause the module to kick
itself out.  The allocation for the ready event could force a garbage
collection and nothing has a hard reference to the ModuleInfo or the
Module so it away it goes.  The addEventListener is not a hard reference
to the ModuleInfo, the reference goes the other direction.

 

The answer here is to make sure you store your modInfo references on the
instance and not in a local variable.  Similarly, if I kept only one
reference, several calls to loadModule would overwrite the last
reference and allow it to get kicked out.  If you're loading several
modules, you'll need an array of ModuleInfos tracking each module and
administrate their clean up.

 

ModuleLoader keeps hard references so it should be ok, as there should
be one ModuleLoader per url.  But again if you ask it to load more than
one module, the previous ones may be eligible for garbage collection.

 

If you're using 2.0.1, calls to unload() could cause the same sort of
situation.

 

-Alex

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mark Doberenz
Sent: Monday, December 10, 2007 7:20 PM
To: [email protected]
Subject: Re: [flexcoders] Re: ModuleLoader 'SWF is not a loadable
module' Error

 

I've worked on an app too where I used modules heavily.  I had/have
issues where the module doesn't load.  I've noticed that the trace log
shows that the SWF is decompressed, but it never throws the Complete
event.  I've found that sometimes recompiling the app will work. 

I'm not sure if it's an ApplicationDomain issue or not.  I tried
tweaking this a while back and never got anywhere, but once I removed
it, the modules started loading.  I didn't have issues with it anymore
until just recently when I started the project back up again.  It made
me not work on the app b/c I'm tired of hacking with this issue. 

Unfortunately, I haven't found a way to really fix this. :(

Mark

On Dec 10, 2007 5:42 PM, Alex Harui <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

GC = garbage collection.  W/o a hard reference, the memory manager could
remove your module.  ModuleLoader should be ok hanging on to it.  It
might be possible that if you start two loads of the same swf that the
second one doesn't finish.  Not sure how to prove that.

 

I would try to make the smallest possible test case that can reproduce
the error.

 

________________________________

From: [email protected] <mailto:[email protected]>
[mailto:[email protected] <mailto:[email protected]> ]
On Behalf Of Barry Evans
Sent: Monday, December 10, 2007 1:47 PM


To: [email protected] <mailto:[email protected]> 
Subject: [flexcoders] Re: ModuleLoader 'SWF is not a loadable module'
Error

 

Sorry, i forgot to say i'm using flex 2.0.1.

And as for a hard reference, i am creating a number of ModuleLoader 
components within a repeater, so the url of the loaded module is 
dynamic in nature.

What do you mean by a GC?

The weird thing in this situation is that i have another module which 
displays links and is very close in nature to the one giving me 
problems, however it never produces any errors.

I use the problematic module on more than one occassion i.e. when the 
app loads up, the links module is loaded twice. Its only means of 
consistently is that it fails both times it loads (in a single 
application instance).

I am also passing data to the module (on the moduleReady event) using 
a custom Interface, i wonder if this would have any affect?

I followed the Adode dev guide on how to pass data to the module, so 
im not sure this is where the problem stems from, but i thought i 
would mention this.

The only other issue that comes to mind is the sequence in which the 
modules are loaded, but i havent had a chance to apply the 
ModuleLoader's urls manually, and i dont even think this would be the 
problem, just a thought.

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Which version of Flex? Are you keeping a hard reference to the 
module?
> Otherwise, a GC can kick it out just as it finishes loading.
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>

[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Barry Evans
> Sent: Monday, December 10, 2007 9:50 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: ModuleLoader 'SWF is not a loadable 
module'
> Error
> 
> 
> 
> No, this is not the case im afraid.
> 
> Sometimes the module loads perfectly and the application is fine, 
but 
> sometimes the application throws the error i mentioned in the first 
> post.
> 
> I catch the main error being thrown by the module loader ('SWF is 
not 
> a loadable module'), but when this occurs the ModuleManager.as 
class 
> (from the Flex framework) always throws an error at line 669:
> 
> The code at this line is:
> moduleEvent.bytesLoaded = loader.contentLoaderInfo.bytesLoaded;
> 
> I have changed the code in ModuleManager.as to now point to the 
> correct object - the event.currentTarget.loader property - (so that 
a 
> null pointer error is not thrown):
> moduleEvent.bytesLoaded = 
> event.currentTarget.loader.contentLoaderInfo.bytesLoaded;
> 
> I am not sure how to compile the application (or perhaps rebuild 
the 
> framework.swc file with the new source code) with the changes
> 
> Either way, the module is not loading properly in a consistent 
> manner, and i am totally confused as to how this would be happening.
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
<mailto:flexcoders%25> 
40yahoogroups.com <http://40yahoogroups.com> >
> , "Alex Harui" <aharui@> wrote:
> >
> > is it possible it isn;t a module
> > 
> > ________________________________
> > 
> > From: [email protected]
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
<mailto:flexcoders%25> 
40yahoogroups.com <http://40yahoogroups.com> >
> 
> [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
<mailto:flexcoders%25> 
40yahoogroups.com <http://40yahoogroups.com> >
> ] On
> > Behalf Of Barry Evans
> > Sent: Monday, December 10, 2007 3:51 AM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders% <mailto:flexcoders%25> 
40yahoogroups.com <http://40yahoogroups.com> > 
> > Subject: [flexcoders] ModuleLoader 'SWF is not a loadable module' 
> Error
> > 
> > 
> > 
> > I am having a problem with a modularised application i am 
> developing.
> > 
> > I am using modules to load a user-customised application and i am 
> > getting intermittent errors when loading a certain module (SWF is 
> not 
> > a loadable module).
> > 
> > Having scoured the internet for details of the error, i can only 
> find 
> > answers where the problem is to do with security issues (loading 
> > modules from different domains/crossdomain.xml etc.).
> > 
> > I am loading all my modules from a relative path 
> > (/modules/navigation/Linksmodule.swf) so security should not be 
an 
> > issue.
> > 
> > I would really appreciate some help with this anyone might have 
as 
> i 
> > am reaching a release date for the project and i cannot get by 
> > without solving this problem.
> > 
> > Thanks in advance.
> > 
> > Barry
> >
>

 

 

Reply via email to