views:

52

answers:

1

I have a ProgressBar in MANUAL mode responding an URLLoader's progress events that seems to get drawn far less frequently than I would like. If I debug the app, I can see many events firing from the URLLoader yet it seems that the ProgressBar is being re-drawn at some random and slow rate.

Now if this was my own code (URLLoader is a black box), I would pause once in a while to let the UI update, say via loop with a timer. I presume that the URLLoader itself is blocking the main thread from processing drawing code. Adding validateNow() and invalidateDisplayList() does not seem to help much.

private function onLoadProgress(resource: TResource, evt: ProgressEvent): void 
{
  _progressDialog.prbCurrentItem.setProgress(evt.bytesLoaded, evt.bytesTotal);
  _progressDialog.prbCurrentItem.validateNow();
  _progressDialog.prbCurrentItem.invalidateDisplayList();
}

Now there are many TResources (just a class that can manage its data) being loaded in sequence, but the URLLoader is so greedy that it does not let the UI get updated more than a few times when loading & processing (parsing into XML objects) 50 or so 10KB files. So just counting which files loaded visually does not work either; I'm lucky to get 2-3 screen updates the entire time.

Loading a 700MB file looks much better, but again the progress bar updates are random and slow.

Additionally, I'd like to know if there is any way to influence or even control the rate at which ProgressEvents are fired by the URLLoader class. I have not been able to find at what rate it normally dispatches progress events either; is it at a fixed percentage per file or every x frames or milliseconds?

As these are local files, would I be better off not using the URLLoader class and instead switching to FileStream?

Environment

  • Flex 4.1.0.16076 SDK
  • Compiling to AIR app
  • App frameRate is 60
  • OS is Windows 7 x64

My bad, should have looked harder.

  .-'---`-.
,'          `.
|             \
|              \
\           _  \
,\  _    ,'-,/-)\
( * \ \,' ,' ,'-)
 `._,)     -',-')
   \/         ''/
    )        / /
   /       ,'-'
A: 

Provided that you have a regular connection , it is actually surprising that the loading progress of a 700MB file is not accurately represented with your Progress Bar. You also state that when debugging you can see the events being fired. This would lead me to think that the problem is on the display side. You have provided the code for the progress listener, it would be interesting to see what the code does on the view.

Displaying loading progress is quite a common task which works fine on many applications, so , although this can't be excluded , I wouldn't blame URLLoader right off the bat. Do you have any other processes going on whilst loading , any possible interferences?

PatrickS
The connection is SATA to a HDD; I am using URLLoader to load local files at the moment. But it seems you are correct, I found some code in a library that was blocking the main thread, so URLLoader is not to blame at all. Now everything is smooth.
Alan G.