[Project_owners] Not aborting scripts.
frank at supportware.net
Fri Jun 25 08:06:33 EDT 2004
----- Original Message -----
*From:* Christopher Ottley <xknight at users.sourceforge.net>
*To:* Mozdev Project Owners List <project_owners at mozdev.org>
*Sent:* Friday, June 25, 2004 1:48:06 AM
*Subject:* [Project_owners] Not aborting scripts.
> Hello all,
> I've been testing my extension with the released version of Firefox
> 0.9 for Linux and in one of my tests I get the following message:
> "A script on this page is causing mozilla to run slowly. If it
> continues to run, your computer may become unresponsive. Do you want
> to abort the script?"
> If I press cancel each time this comes up, eventually my script
> finishes. Is there a way to disable this? I tried setting the
> preference dom.max_script_run_time to 600 (was originally 5) but no
> effect. Alternatively, is there an explicit thread yield type function
> My test case is a bit excessive, manipulating 400+ KB of a string, but
> it is a possible case when using my extension.
This too had been a problem for me when creating my 'Attachment Tools'
extension. I was/am manipulating text strings of up to 20,000KB!. What
I did ( do not know if there is a better way ) is:
I wrote a function that loops through the lines one at a time ( lets
call it loopFunction)
I call that function from another function using a
When the loopFunction had processed 1000 lines, the Loop function :
...a) called itself using setTimeout(loopFunction,1,params)
...b) then ended
When the loop function completed all lines, it calls whatever comes next.
What the setTimeout() call does is puts the function call on a stack of
functions to call in time. But if the timeout passes and other
operations are still running, your function will run immediately after
everything else has been processed ( like UI draws, mouse clicks, etc)
so in effect, the setTimout() call is similar to a 'thread yield'
function ( or at least *I* used it that way with positive results
The opinions presented herein are those of Frank DiLecce,
replies to those opinions should be mailed to trash at garbage.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Project_owners