View Full Version : thread creation / flash errors
scorpio
05-20-2004, 07:47 AM
Hi,
Is it possible to create a thread for data-processing?
Basically i have to process a large set of data and it takes a long time and usually causes a flash error "Script is causing Flash to run slowly do you want to abort script?". Is there a way to disable this error?
any tips that will allow for more efficient data process would be very helpful...
thanks.
antun
05-20-2004, 09:16 AM
There's no way to disable the error, but if you can give me an overview of what kind of data processing you're doing, I might be able to point you in the right direction.
-Antun
scorpio
05-20-2004, 09:35 AM
Hi antun,
well i have a dataset that sends a http request and gets back a very large XML ( many record and each record has about 20-30 fields inside )
I use the xml to drive GUI components (eg. x, y positions etc) as based on certain actions we also append to the XML.
I also have another process which periodically asks for data using a http request and gets back an XML but this thing doesn't append any data to the XML.
Somebody came up with an idea that a thread should be used in the background which does the data processing. Is this a good approach and if it is how do i use threads in laszlo?
thanks.
antun
05-20-2004, 10:39 AM
well i have a dataset that sends a http request and gets back a very large XML ( many record and each record has about 20-30 fields inside )
I use the xml to drive GUI components (eg. x, y positions etc) as based on certain actions we also append to the XML.
If that's the case, then the script running slowly errors are most likely caused by view instantiation. How many views are being created as a result of your data?
-Antun
scorpio
05-20-2004, 11:00 AM
well i am instantiating about 20-30 views that depend on XML. And these views also have to do additional calculations for other gui components.
antun
05-20-2004, 11:07 AM
20-30 views doesn't sound too bad. However, is it 20-30 views, or 20-30 views that each contain a certain number of subviews?
-Antun
scorpio
05-20-2004, 11:59 AM
we have 20-30 classes that represent gui components and each gui components contains other basic elements like text, buttons, views, etc..
antun
05-20-2004, 12:35 PM
I see. If each of your classes that is data driven has (say) 6 views in it (more if you're using a Laszlo component, since they all have more subviews) that means it's creating 7 views, so your're actually creating 20 - 30 * 7 = 140 - 210 views. That's a fair number to be creating at once.
Are all of the 20-30 views visible at app startup? You might be able to defer/lazily replicate them so that they don't all get created at the same time. In effect you defer the instantiation of them until they're required.
-Antun
scorpio
05-20-2004, 01:26 PM
unfortunately we need all these views. We have already difered all unnecessary views to be instantiated later on when they are absolutely necessary.
Is there a way we can either make the application load faster or pool already created object by ourselves?
vfunshteyn
05-28-2004, 10:46 AM
Let me start by saying that you cannot create your own threads in Flash. This is partly because the Flash player is a single threaded environment. Nor is there any kind of built-in thread management in Javascript. You simply don't have that level of control of the runtime (nor does the LFC). So we can certainly rule out background thread creation as a possible solution.
I'd look for the cause of the slowdown elsewhere. I bet the problem is not the number of views instantiated simultaneously, but rather the size of the dataset returned to the runtime by the server. Flash 5 is notorious for freezing up whenever anything larger than a few hundred KB of XML gets encoded and sent to it. Flash 6 is much better about, but it's also possible to hang it in the exact way you are describing by sending it a very large dataset.
The best approach in this case would be to redesign your application and restructure your data so that the client requests it in smaller chunks, as it needs it - this is sometimes known as paging. It will also significantly improve perceived startup time of your application.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.