Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1] 2
1  Announcements and General Discussion / Fabrication / Re: proxyNameCache is null inside FabricationProxy on: September 13, 2009, 10:22:51
Ok I think I found the answer but any of you more seasoned Fabrication guys can correct me if I'm wrong.
After some searching around I found this post http://lowpitch.com/blog/puremvc-multicore-vs-standard-singlecore/
So I thought I would check to see if that method was in FabricationProxy and it was. After adding the method to my proxy all is fine.

   override public function initializeNotifier(key:String):void {
         super.initializeNotifier(key);
         
         initializeProxyNameCache();
         // initialize methods in proxy after this
      }
2  Announcements and General Discussion / Fabrication / Re: Fabrication UnitTestCase on: September 13, 2009, 10:20:42
   After some searching around I found this post http://lowpitch.com/blog/puremvc-multicore-vs-standard-singlecore/ So I thought I would check to see if that method was in FabricationProxy and it was. After adding the method to my proxy all is fine.

   override public function initializeNotifier(key:String):void {
         super.initializeNotifier(key);
         
         initializeProxyNameCache();
         // initialize methods in proxy after this
      }
3  Announcements and General Discussion / Fabrication / proxyNameCache is null inside FabricationProxy on: September 12, 2009, 02:40:11
Error #1009: Cannot access a property or method of a null object reference. thrown on sendNotification inside a proxy

I have two proxies instantiated in my application startup command however one is coming up null unless I use a setTimeout inside the proxy to send notifications.  I tried changing the order of instantiation and even tried an addProxyCommand.

The debugger points to a null value inside FabricationProxy and sure enough proxyNameCache is null inside FabricationProxy line 212 unless I add some kind of delay in witch case it is fine.  The weird thing is both proxies send notifications so why does one throw the error and the other not.  They both have static public const NAME:String="Name of Proxy" and call super(NAME); in their constructor.  Both extend FabricationProxy

The only thing that prevents the error is using a setTimeout to send the notification
4  Announcements and General Discussion / Fabrication / Re: Fabrication UnitTestCase on: September 11, 2009, 11:33:46
Hi JK,

I am working with a modular Fabrication application and I recently added a new proxy to get the swf host information and client capabilities information. When those methods completed I needed to send a notification to the mediator. As soon as I added sendNotification I got the same error you describe.  It seems as though the proxy is instantiated before the fabrication can map the class.  I tried moving the order of the instantiation of the proxy to last without any improvements.  I then added setTimeout(send,1) inside that method instead of just sendNotification() and added the function like so...
      private function send():void {
         sendNotification( CommonConstants.CLIENT_DATA, browser_object );
      }
This fixed the issue although I am not happy with the word fixed since it is more of a hack.
5  Announcements and General Discussion / Fabrication / another way to clean up on: August 02, 2009, 05:55:16
I read in a post elsewhere from Darshan Sawardekar

"In fabrication the module’s facade instance is disposed when unloading the module. A "shutdown" notification is fired before the facade is disposed to allow any custom cleanup to happen inside the module. Typically, a command can register with this notification to execute cleanup within the module."

I tried this by registering a command for this notification in both my shell and module startup commands and neither one would execute.

inside startup command

registerCommand(FabricationNotification.SHUTDOWN, ModulelShutdownCommand);

the ModulelShutdownCommand

   import org.puremvc.as3.multicore.interfaces.INotification;
   import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;

   public class ModulelShutdownCommand extends SimpleFabricationCommand {
      
      override public function execute(note:INotification):void {
         trace("FABRICATION SHUTDOWN");
      }
   }

I am calling dispose() but perhaps I am calling it in the wrong location.  I am not using FlexModuleLoader because my project is Actionscript only.
In the simple routing example it is called after removeChild but I am doing it prior to remove child because   it adversely affected garbage collection like so...

            var moduleName:String = getModuleName(moduleID);
            loaderDict.content.fabricator.dispose();
            loaderDict.content.dispose();
            loaderDict.unloadAndStop(true);
            delete(loaderDict);
            startGCCycle();
            application.removeChild(application.getChildByName(moduleName));

I tried calling dispose in the module on itself as well as in the shell on the module and from the shell produced better memory recovery. I have changed the sequence of removeChild to last because it allows for better garbage collection.  I believe I am doing the same calls as in FlexModuleLoader except for it being still on the display list.

Has anyone else had success with using the SHUTDOWN notification?
Does anyone have another example of how to and when to call dispose?
6  Announcements and General Discussion / Fabrication / Re: Memory management in pure Actionscript module load and unload on: August 01, 2009, 08:34:08
I found a solution.  I tried removing all the UIComponents and still had the issue with the shell retaining 2/3 of each loaded module. So this led me to believe it is not a UIComponent issue even though the Flex profiler shows a [listener0] as the cause.  I decided to take another look at a similar project (http://www.nutrixinteractive.com/blog/?p=132&cpage=1#comment-30581) claiming to be able to recover all the memory after the first module load, so from the second module on. 

According to Cliff and Adobe "When a module is loaded by the Flex application for the first time, the module’s SWF file is transferred across the network and stored in the browser’s cache. If the Flex application unloads that module, but then later reloads it, there should be less wait time because Flash Player loads the module from the cache rather than across the network.
So, although Flex GC may have released its reference to the loaded module, it will still consume system memory until the browser has flushed its cache. This is seen as a positive thing from a reuse standpoint if you create more instances later, but may not be what you want if you’ve loaded a huge module, only want to use it once and then wish to get rid of it altogether. That might actually require talking to some external JavaScript in the browser to tell it to flush its cache. I don’t even know if that’s possible. But it does explain why sometimes after loading and unloading a module, you still see some memory gone missing."

Any way I digress. The trick is the location of removeChild. I commented out the prior location..

            var moduleName:String = getModuleName(moduleID);
            //application.removeChild(application.getChildByName(moduleName));
            loaderDict.content.fabricator.dispose();
            loaderDict.content.dispose();
            loaderDict.unloadAndStop(true);
            delete(loaderDict);
            startGCCycle();
            application.removeChild(application.getChildByName(moduleName));

And it worked. Before the shell's memory usage would grow after every module load/unload now after the first module it grows by 2/3 and everything else after that is fully recovered. I believe that display objects need to be on stage for the event cycles to run or even be removed properly.

I will try to post my examples soon.
Greg
7  Announcements and General Discussion / Fabrication / Re: Not working with Flex 4 SDK on: July 30, 2009, 05:06:35
I'm not sure if it is related but I just ran into a similar issue. It turned out to be in FabricationMediator line 292 var respondToMethodsCount:int = respondToMethods.children().length();
In the debug length was 8 but the actual xmllist was 3.  I took out children() and it started working?

like so

var respondToMethodsCount:int = respondToMethods.length();

The only thing I can assume is perhaps something is changed in how FB 4 handles xmllist or reflection in general.  In my case the swf wouldn't even render so I followed the debug error to the listNotificationInterest function in FabricationMediator
8  Announcements and General Discussion / Fabrication / Re: Memory management in pure Actionscript module load and unload on: July 29, 2009, 09:21:29
Originally I did that in the module's application mediator however I found I was able to manage memory better if I performed all that in the shell's application mediator by using a unique id reference in the module and storing a reference to each modules loader in a Dictionary with a weak reference(see update#2 in my first post).  I am also on a quest to find the method of removing the core or whatever is left behind when I null everything on the display list and remove all listeners.  Quite frustrating! I still retain approximately two thirds of the loaded state memory usage..
9  Announcements and General Discussion / Fabrication / Memory management in pure Actionscript module load and unload on: July 27, 2009, 02:20:33
I have a pure Actionscript project that loads and unloads modules.  Since all the examples that unload modules are MXML based I dont have a clear idea of best practice.
So inside a loaded modules mediator I do this after notifying the shell...
               application.parent.removeChild(application);
               application.dispose();
               this.viewComponent = null;
Inside the shell I clear out any reference to the module and call System.gc();

The memory usage goes up with every module and never comes down so I wanted to get some feedback on what I am doing so far.  The module does not have any proxies but if it did what would be best practice?
In a strictly PureMVC Multicore project I would call removeMediator, removeProxy, pipe.disconnect(),
and junction.removePipe().
Again not sure what to do in my case?  I believe dispose() takes care of the pipes, junctions and core but since I am not handling this with FlexModuleLoader the correct methods are a mixture of what I have seen or adapted from other examples and it isn't working.  I'm not sure how to reference the module from the shell once its loader is cleared out.  I considered keeping the loader in an array to reference by index in the shell then the shell could call removeChild(moduleLoader) instead of the module calling application.parent.removeChild(application).
The current loading method follows Hello Flash method with one slight change.
I store the load index and a unique id in the config object of each module. The shell also maintains a hash map with all current modules index and unique id.

         var content:FlashApplication = moduleLoader.content as FlashApplication;
         var moduleID:Object = new Object();
         moduleID = {(index as Number):unique_id}
         content.router = applicationRouter;
         content.defaultRouteAddress = applicationAddress;
         content.config = moduleID;
                        application.addChild(content);

Any clarity would be appreciated.  Step by step would be awesome.
Thank you

Update
I tried the method I eluded to above and placed the loader in an array. This yielded a minor improvement but I am unable to get closer than 1/2 meg of the original memory usage.


Update#2
     I changed the array to a Dictionary(true) to allow for better cleanup.
     I get the child through a reference with its unique ID, removeChild and then call the
     loader.unloadAndStop(true) then I delete the loader from the loaderDictionary.
     For some reason calling application.dispose() works better when called from the shell on the module?
     If I call it from the module mediator the memory usage is the same as if the module is still loaded.
It looks like so...
            var moduleName:String = getModuleName(moduleID);
            application.removeChild(application.getChildByName(moduleName));
            loaderDict.content.config = null;
            loaderDict.content.fabricator.dispose();
            loaderDict.content.dispose();
            loaderDict.unloadAndStop(true);
            delete(loaderDict);
            startGCCycle(); // Does not make a difference
            sendNotification(CommonConstants.GARBAGE_COLLECTION);

I am able to reduce memory by only .4 meg from its loaded state so...
shell startup = 5.5 meg
load module = 6.4 meg
remove module = 6.0 meg

I hope someone can help me improve on this.

Thank you
10  Announcements and General Discussion / Fabrication / Re: respondTo fails but handleNotification works on: July 24, 2009, 09:51:06
That was it! I had those functions in both module and shell.  It goes to show sometimes a person needs to look at what is NOT in a working example in comparison to their code.  The exclusion of those functions should be documented for all of us who come from PureMVC Standard, Multicore and Pipes.  I knew it had to be something simple because I could see the routes being set in the debuger.  I really appreciate people like you who take the time to help.  Thank you sooo much!!!

One other question is there a way to connect modules or should I just bounce messages off the shell, rely on the shell to route them?  I have a routeNotification("moduleModule") and respondToModuleModule in both modules that does not work.  I understand a module won't respond to it's own notification.
11  Announcements and General Discussion / Fabrication / Re: respondTo fails but handleNotification works on: July 24, 2009, 02:40:26
Thanks for the input Jason,
You say my mediator should extend FlexMediator however I am not using any mx classes it an Actionscript project with flash and fl with no MXML at all.  The Hello Flash mediators extend FlashMediator and my code matches the example.  I am not sure how FlashMediator could work since it is empty compared to FlexMediator.  It does not have any route mapping, class maping or reflection of any kind. FlashMediator extends FabricationMediator wich has these methods inside listNotificationInterests().
I placed a debug marker in FabricationMediator listNotificationInterests() and it never executes.  I wonder if something is missing from the latest release?  I even tried using source zip vs swc no difference.
There must be something I'm missing since Hello Flash uses routeNotification and respondTo ?
A couple of other differences are my file structure My Shell.as and Module.as files exist outside of org, com and fl and I have not implemented a proxy.  Only one of the, I believe four, routeNotifications goes through the proxy though. The final difference is I have a button in the shell to load a module so it is not loaded when ShellMediator onRegister runs.
12  Announcements and General Discussion / Fabrication / Re: respondTo fails but handleNotification works on: July 23, 2009, 09:08:00
It is documented in first post CommonConstants.SHELL_TO_MODULE="shellModule"
in Module...
public function respondToShellModule(notification:INotification):void{trace("response recieved");}

I have checked and re-checked this and tried using a plain string instead of
static public const SHELL_TO_MODULE:String= "shellModule";
I have tried using the default route instead of specifying "*"
I have tried using a single word like "talk" with respondToTalk???
Thanks anyway.

I am also curious if a module can obtain a route to another module or should I bounce module to module messages off the shell letting the shell act as a switchboard.
Any more ideas?
13  Announcements and General Discussion / Fabrication / respondTo fails but handleNotification works on: July 23, 2009, 04:17:19
Hello,

I have built Module and Shell Actionscript only projects using PureMVC, Pipes and Fabrication.  I load Module.swf into Shell.swf like so...
req = new URLRequest("Module.swf");
moduleLoader = new Loader();
moduleLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
moduleLoader.load(req);

in completeListener...

var content:FlashApplication = moduleLoader.content as FlashApplication;
content.router = applicationRouter;
content.defaultRouteAddress = applicationAddress;
application.addChild(content);
This seems to be working great, both Module and Shell receive notifications frome each other fine however routing is not working?

in Shell...
routeNotification(CommonConstants.SHELL_TO_MODULE,null,null,"*");//SHELL_TO_MODULE="shellModule"
in Module...
public function respondToShellModule(notification:INotification):void{trace("response recieved");}

I am lost as to how to debug this.  I can inspect the properties of both the module and shell with the Flex debugger but I'm not sure what to look for.  Both router and defaultRouteAddress seem to be getting set. The defaultRoute in the module is set to Shell/Shell0/INPUT.  The applicationAddress is a fabrication.vo.ModuleAddress that is not readable but it is set b in the module so applicationAddress in Shell = (@1b6fda39) and Module defaultRouteAddress = (@1b6fda39). 
The pipes are connected since notifications are sent and received but why are routeNotifications failing?

I have been through the HelloFlash example numerous times and I cant see any differences other than my not using fla files.  There must be something else failing because routeNotification is sending the note fine but only handleNotifications is receiving, respondTo fails?

Any advice is welcome.  Thank you
14  Announcements and General Discussion / General Discussion / should proxy share notifications? on: February 14, 2009, 08:47:32
I have an application that allows customers to preview media, login purchase and and view full library.
Init proxy returns the preview and price only. Login and buy proxy returns the complete library.
There was a request for maintaining the logged in state if a user returns to the page. I now check for a stored session id in a shared object in my init proxy. If it exists I post it to my API and get the complete library back.
My Question
Should I handle the new post structure in init proxy or communicate the session to a application mediator and then handle it in the login proxy.
My other finding.??? I can send the login proxy notification to my application mediator from the init proxy and application mediator handles it as if it came from login proxy and I don't need to write any additional code to handle the response because the structure is already there to handle it ...
Weird.  I guess the proxy's are in the same package so if the sendNotification is public that would explain it
15  Announcements and General Discussion / Getting Started / Delayed command and proxy registration? on: August 12, 2008, 06:34:02
My application needs to give the user a 30 second video followed by a login screen and the option to go directly to the login at any point.
InitProxy gets access to a 30 the second clip url.
loginProxy gets access to the full length video url

InitProxy is registered in StartupCommand.

When and where should I register the loginProxy?
If I use a LoginCommand to register LoginProxy when and where should I register the LoginCommand?

I believe that I need to register them in ApplicationMediator on the event from the view but I have not seen any examples of this.
All the examples assume login is the first action and so registration is always in StartupCommand.  If anyone knows of a deferred registration example please post it.
Thank you
Greg
Pages: [1] 2