JavaScript Experts, How Do I Debug This Event Handlers Problem?

Discussion in 'Javascript' started by Ray, Mar 7, 2007.

  1. Ray

    Ray Guest

    Hello JavaScript experts,

    I've been racking my brains for 2 hours and I still haven't figured
    out this problem.

    Basically, I have this page (an IE-only page), with a lot of
    javascript files behind it, most of it not written by me. The problem
    with this page is: once I use IE6 to load it, moving the mouse pointer
    over the page will cause IE CPU usage to shoot up to 100%. Typing into
    edit boxes a lot of characters quickly will also choke the CPU (and
    the characters won't show up immediately, it took a few seconds before
    the chars I type appear within the text box).

    So, obviously something is catching keyboard and mouse related events
    somewhere and doing useless, but intensive, processing.

    And my guess is that since moving the mouse _anywhere_ within the page
    (as long as it is within the browser window) jacks the CPU usage up to
    100%, it's probably handled at the document level.

    My question is, how do I find out the culprit? I tried this:

    * Find all files with the text "document.attachEvent", I found them,
    commented them out, still have the same problem. (Also, actually the
    lines I commented out trap onkeyup and onmousedown, so it doesn't
    explain the "moving-mouse-uses-100%-CPU" problem).

    * There doesn't seem to be any API for finding out all the event
    handlers attached to an element?

    Thanks in advance for any pointers,
    Ray
     
    Ray, Mar 7, 2007
    #1
    1. Advertising

  2. Ray

    wisestpotato Guest

    The event could be being trapped on either the document or the body
    element. Have you checked for events attached to both? Have you
    searched for event handlers created using the "element.onmousemove
    = ..." syntax?

    You say that the page is IE-only, does that mean that loading it in
    either Opera or Firefox and using their debugging facilities is not an
    option? Unfortunately, trying to debug javascript in IE6 is a
    frustrating experience.

    wp
     
    wisestpotato, Mar 7, 2007
    #2
    1. Advertising

  3. Ray

    Ray Guest

    On Mar 7, 11:57 pm, "wisestpotato" <>
    wrote:
    > The event could be being trapped on either the document or the body
    > element. Have you checked for events attached to both? Have you
    > searched for event handlers created using the "element.onmousemove
    > = ..." syntax?


    Let me give that a try... the use of Behaviour.js complicates things
    actually, although I guess I can search using onmousemove, let me
    try.

    > You say that the page is IE-only, does that mean that loading it in
    > either Opera or Firefox and using their debugging facilities is not an
    > option? Unfortunately, trying to debug javascript in IE6 is a
    > frustrating experience.
    >
    > wp


    Yes, IE-only as in when I opened it in Firefox (I wanted to debug this
    using Venkman, alas, I couldn't), the page becomes really screwed up,
    things that usually work don't work anymore, etc.

    Thanks!
    Ray
     
    Ray, Mar 7, 2007
    #3
  4. Ray

    Ray Guest

    On Mar 7, 11:57 pm, "wisestpotato" <>
    wrote:
    > The event could be being trapped on either the document or the body
    > element. Have you checked for events attached to both? Have you
    > searched for event handlers created using the "element.onmousemove
    > = ..." syntax?


    Hmmm, that's really strange. I didn't find onmousemove that is
    relevant. I tried moving my mouse pointer over the part that doesn't
    have any element (so it's basically either the body or document)--CPU
    immediately shoots up to 100%. Really strange.

    >
    > You say that the page is IE-only, does that mean that loading it in
    > either Opera or Firefox and using their debugging facilities is not an
    > option? Unfortunately, trying to debug javascript in IE6 is a
    > frustrating experience.
    >
    > wp
     
    Ray, Mar 7, 2007
    #4
  5. Ray

    VK Guest

    On Mar 7, 8:23 pm, "Ray" <> wrote:
    > I tried moving my mouse pointer over the part that doesn't
    > have any element (so it's basically either the body or document)--CPU
    > immediately shoots up to 100%. Really strange.


    That can be some library implementing paranoidal DOM event model: so
    onload it makes all elements as event consumers "just in case" with
    custom event dispatcher atop. So on each mouse move the event gets
    distributed to N consumers where maybe only one or two are actually
    supposed to do anything on this event. That is a speculation from my
    side based on what I've seen on practice.

    Comment out all <script> elements and then uncomment one by one
    checking the performance after that. That should help to identify the
    actual "abuser". Then give us a link to the abusing library.
     
    VK, Mar 7, 2007
    #5
  6. Ray

    Mister Joe Guest

    On Mar 7, 10:31 am, "Ray" <> wrote:
    > Hello JavaScript experts,
    >
    > I've been racking my brains for 2 hours and I still haven't figured
    > out this problem.
    >
    > Basically, I have this page (an IE-only page), with a lot of
    > javascript files behind it, most of it not written by me. The problem
    > with this page is: once I use IE6 to load it, moving the mouse pointer
    > over the page will cause IE CPU usage to shoot up to 100%. Typing into
    > edit boxes a lot of characters quickly will also choke the CPU (and
    > the characters won't show up immediately, it took a few seconds before
    > the chars I type appear within the text box).
    >
    > So, obviously something is catching keyboard and mouse related events
    > somewhere and doing useless, but intensive, processing.
    >
    > And my guess is that since moving the mouse _anywhere_ within the page
    > (as long as it is within the browser window) jacks the CPU usage up to
    > 100%, it's probably handled at the document level.
    >
    > My question is, how do I find out the culprit? I tried this:
    >
    > * Find all files with the text "document.attachEvent", I found them,
    > commented them out, still have the same problem. (Also, actually the
    > lines I commented out trap onkeyup and onmousedown, so it doesn't
    > explain the "moving-mouse-uses-100%-CPU" problem).
    >
    > * There doesn't seem to be any API for finding out all the event
    > handlers attached to an element?
    >
    > Thanks in advance for any pointers,
    > Ray




    http://blogs.msdn.com/ie/archive/2004/10/26/247912.aspx
    http://www.jonathanboutelle.com/mt/archives/2006/01/howto_debug_jav.html

    Check the two links above. I think the debugger is pretty weak but it
    may help you out some. Also could you be more specific about things
    not working in ff. When you check the error console do you see signs
    that certain functions are not recognized? If you do then check your
    js source code b/c those may be the functions that are causing the
    problem.
     
    Mister Joe, Mar 7, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Millman

    Debug step into event handlers

    Robert Millman, Jul 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    Robert Millman
    Jul 29, 2003
  2. Deryck
    Replies:
    7
    Views:
    98
  3. yawnmoth
    Replies:
    2
    Views:
    180
    yawnmoth
    Dec 24, 2005
  4. yawnmoth
    Replies:
    3
    Views:
    158
    Lasse Reichstein Nielsen
    Jun 24, 2006
  5. Safalra
    Replies:
    2
    Views:
    135
    -Lost
    Mar 30, 2007
Loading...

Share This Page