face08 / bulk-loader

Automatically exported from code.google.com/p/bulk-loader
0 stars 0 forks source link

percentWeight returns unreliable results if clearMemory set to true #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Not sure if this is a expected behavior. But this is what I found. It
really throw me off for several hours:

What steps will reproduce the problem?
1. This is my commented code:

//remove any previous loaders 
BulkLoader.removeAllLoaders();

//create a new one. Will load files 1 at the time
_mediaLoader = BulkLoader.createUniqueNamedLoader(1);

// add files to load
for (var _i:int =0; _i< _totMedia; _i++)
{ 
  _mediaLoader.add( _mediaArr[_i], {"id":String(_i), preventCache: true });

  // event for individual Item
  _mediaLoader.get(_id).addEventListener(Event.COMPLETE, _onFileLoaded,
false, 0, true);
  // EVENTS FOR THE _mediaLoader as a group
  // dispatched when any item has progress:
  _mediaLoader.addEventListener(BulkLoader.PROGRESS, _onProgressMedia,
false, 0, true);
  // now start the load
  _mediaLoader.start();
}

2.
// listener to measure progress of all loads

private function _onProgressMedia(e:BulkProgressEvent):void
{   
  trace ("PERCENTAJE OF ASSETS LOADED:", e.target.weightPercent,
e.weightPercent,  e.target.itemsLoaded, e.itemsLoaded);
}

3.
// called each time a file is loaded
// IF CLEARCACHE SET TO TRUE, THE weightPercent, itemsLoaded, itemsTotal
values go NUTS.

private function _onFileLoaded(e:Event):void
{
  trace ('file loaded');
  e.target.removeEventListener(Event.COMPLETE, _onFileLoaded);
  var _id:String = e.target.id;
  var _theLoad:* =  _mediaLoader.getContent(_id, true);
 }

What is the expected output? What do you see instead?

I was expecting to see a progressive report of my load: 0, 5, 8, 12, 22,
35, ..100%. 

That's fine when clearCache is set to false. If set to true instead I get this:
0, 3, 5, 15 (first item loaded),
0, 2, 9, 18, 25 (second item loaded),
0, 11, 19, 30, 33 (third item loaded),
... 
0, 6, 12, 15, 35, .., 80, 90, 100 (last item loaded)
then reports zero two or three times.

This completely screws my loading bar (it keeps jumping back and forth, and
then it disappears!).

Anytime an item finishes loading, the weightPercent report starts from
zero, and finishes at a percentage a little higher (I think this final
percentage is the right value for the accumulate though). 

What version of the product are you using? On what operating system?

FLASH CS4, AS3, OS X 10.5.6, BulkLoader rev 282

Please provide any additional information below.

Original issue reported on code.google.com by hellolit...@gmail.com on 10 Sep 2009 at 6:50

GoogleCodeExporter commented 8 years ago
Hi Hello Little One.

This is the expected behaviour, I am afraid. 
Once we clear from memory, BulkLoader simply forgets that asset enterly. This 
means that the it also removes it from the aggregates in progress book keeping.

I think this warrants a documentation improvement to make that clear.

One thing to notice it that the usual workflow is to load stuff you need, then, 
when 
the entire loading is done, clear those items. This makes sense since if you 
are 
clearing those items while loading and using them, the memory gain will be 
minimal.

Cheers 
Arthur Debert

Original comment by debert on 10 Sep 2009 at 12:16