Thursday, June 11, 2009

Flashplayer ScriptTimeOutError, A Script has executed longer than 15 seconds

While doing Load testing of the flex application we've developed, we hit upon this scenario where our test load data was so huge that optimizing DB queries, webservice logic, client logic took us more than 60 seconds which is the maximum timeout limit Flashplayer can be increased to.

To find a solution to the problem, I have googled around and found some interesting articles.

When the load data is so huge, and you are tired of optimizing code just to fit in the 60 seconds time intervel before the timeout error is thrown by flash player... I tried to workaround it with a solution that will run for enough time without freezing / breaking your load data...


Here is the sample Flex code that would throw the Flashplayer script timeout error.

Error message -

My Solution to this problem is to workaround by giving flashplayer a breathing time. This is however not a full-fledged code but would completely give you an idea on what i am trying to achieve. The below code would run a timer for say 100 milli-seconds and execute your piece of code which you think is consuming more time... say if you are iterating over 10,000 items with a lot of data or something similar... This solution would run a timer and call it over and over until your job execution is done, when you delete the listener and proceed further with your logic. This way flashplayer break due to heavy load is taken care of. Flash player would get a breathing time to perform any UI operations if any meanwhile. In my actual code at work, i display a popup modal window before the timeconsuming operation begins that displays - "Please wait, while we are processing the data", and i remove the modal dialog once the entire process is done. This way end user feels that he has a feedback from the app and even if it were to take a bit more time, this solution will scale for you even if your load were to increase in more numbers...

See the Solution here (Iterating based on a timer until execution is complete)...

0 comments: