When this happened to me I used alert()s to debug the script because
they halt the execution of the script.

Simple alert('foo'); lines at the top-level of the script before any
function calls or loops or major bits of code etc and counting how
many appear will help figure out where the hanging code starts.

Once you figure out which 'block' is the problem, remove the other
alert()s and add some more specific ones where the problem might be.


Its a primitive way of debugging and the same approach can be used
with GM_log() or console.info() once the script stops hanging, but
afaik its the only way to be sure of seeing each 'message'.


Also, take a look at dom.max_chrome_script_run_time - changing this
preference via about:config should cause the greasemonkey script to
show the 'a script on this page is running slowly; abort or
continue?;' message. This timer will apply to Firefox files too though
so if you set it too low, Firefox will trigger it too often; else too
large and it will hang for longer.


kwah


On 8 August 2011 04:45, John Nagle <[email protected]> wrote:
>  I have a complex Greasemonnkey script which hangs Firefox when working on
> certain pages.
> When Firefox hangs, its visible window greys out, CPU usage goes to 100% of
> one CPU,
> and the program is considered "Not Responding" by Windows.
>
>  I've tried installing FireBug, but when Firefox hangs, so does the Firebug
> window.
>
> (It's probably not a simple "code in an infinite loop", but something more
> like
> change events on the target page triggering change events in the
> Greasemonkey
> script and vice versa.)
>
>  How can I debug this?
>
>                                            John Nagle
>
> (Firefox 5, Windows 7, Greasemonkey 0.9.8)
>
> --
> You received this message because you are subscribed to the Google Groups
> "greasemonkey-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/greasemonkey-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to