I have a web app that I am trying to speed up. It looks like this:
+------+
| |
| |
+------+
+------+
| |
| |
+------+
+------+
| |
| |
+------+
Each box is an iFrame containing a Flash SWF and some javascript. The SWF downloads a thirdparty SWF that is used to display information. I have found that the load time for the webapp is:
LoadTime = (4 seconds) * numberOfBoxes + (3 seconds)
When I just imbed the 3rd party swf directly (without our swf or the javascript) the load time is:
LoadTime = (1 second) * numberOfBoxes + (2.5 seconds)
I am trying to find where the extra 3 seconds is being used so that I can speed up our webapp. I think that the candidates are:
Below is an image of the downloads taken from firebug. I have replaced the file names with what their type is. None of the downloads are taking especially long after the first time.
One place of interest however is marked in red. The red area is a 3 second gap between when My SWF
is loaded and when two gif files are loaded followed by the Third Party SWF
. I think this pause is caused by processing on the client (is this true?).
Note: The red bars in the graph are not part of the diagram. I added them to highlight the gap where nothing is occurring on the .net panel.
I think that I can conclude from this that I have a client side processing issue which implies either Flash or Javascript. Question 1: Is this correct?
Edit: I added up the total non-concurrent download time:
I used the profiler in firebug to profile the javascript. Here are the results when there are four components on the page:
This means that the javascript is running for about .25 second/chart. This seems reasonable to me.
Question 2: Am I reading these results correctly?
This leaves about 3.5 seconds/chart of processing for something else.
I inserted some trace statements in the AS3 code. We are listening to an event called something like "done loading". I put a trace in the first initialize method and in the "done loading" method. The flash is only eating up .2 second/chart between those two trace statements.
Question 3: Is there a better way to to profile the flash? Could it be the flash loading or something like that that is eating up the extra time?
I am not sure if there are other things other than:
Question 4: Is there something that I am missing that could be eating up time?
I am not sure what my next step should be. I know that something is taking about 1.5 - 3 seconds/chart but I cannot figure out what it is. I suspect that it is something related to my swf.
Question 5: How should I find that missing time?
I have graphed all of the times for each thing that could be taking time.
The last graph is possibly the most important graph. The blue dots is the amount of total loading time (measured using a stop watch). The red dots are the amount of time that I have accounted for (Javascript, download time and flash time).
I am targeting IE and Firefox (although it is a nice bonus if other browsers work). All of the results presented so far are with Firefox with firebug running. Just for fun I thought I would try in other browsers. I don't think that this brings me closer to a solution but interesting to see how much IE sucks.
Note: Before running tests for Firefox I cleared the cookies and cache. I did not do this for IE or Chrome
I have been sprinkling console.log
statements though my code trying to sandwich the slow code. (The results get pushed out to the Firebug console).
One thing that I have noticed that seems suspicious to me me is that there is a 2.5 second gap between when my last javascript log gets printed and when my first flash log gets printed.
17:08:29.973 - Javascript code
Time difference: 2510 ms
17:08:32.483 - Flash- myComponent.init()
Does flash need to setup a virtual machine for each swf? Does it compile the actionscript on the client?
What happens between when I <embed>
my swf and when the creationComplete
event in my main .mxml
?
Just some ideas:
Can you eliminate the middle man, in this case, the third party swf?
Where is the third party swf located? If it is on a remote server, you should just have to download it once and then place it on your local server with your other files. That could eliminate download times.
Can you use something like a flash decompiler to decompile the third party swf's code and put the code directly into your swf? (this is probably against the rules)
What happens if you don't put the content in iframes, rather, just put them in divs?
As another option -- try to disable firebug. Is time changes somehow?
Also try the same in chrome -- with and without dev tools.
To understand whether this jsp, that called from your swf or just your swf you can do this:
Do this partly and check the difference.
Also try to profile all newtwork events, that oocurs. May be your SWF calls some method in 3rd party, that calls then some remote method. Here I think we cann't improve this. Only may be if method in 3rd party could be cached somehow. So in your profile we see only loading of files -- we dont' see any other requests -- ajax or something like this.
As per my undertanding, There are three possibilities which the suspects.
Are the iframes coming from HTML response from server? Or, are the iframes added to DOM dynamically via javascript?
You will have better performance by waiting until DOM is ready and inserting iframes into the DOM after page load.
I think the problem is that Flash is blocking script execution while the local SWF downloads the 3rd party SWF. You probably need to figure out how to do a concurrent, non-blocking, asynchronous download of 3rd party SWF using ActionScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With