Closed Bug 137667 Opened 23 years ago Closed 23 years ago

Web Page pegs the CPU at 100%

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
critical

Tracking

()

VERIFIED DUPLICATE of bug 123273

People

(Reporter: dwelch, Assigned: jst)

References

()

Details

Attachments

(3 files)

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc1) Gecko/20020415 Leaving this page causes the CPU to drop. Seen this on the 0.9.9 release build as well as the current 1.0 branch builds. Appears javascript related since disabling Javascript seems to eliminate the issue. Filed as a Javascript bug.
Confirming bug using Mozilla trunk binary 20020415xx WinNT. Loading the page brings the CPU up to 100%, but note the browser does not hang. It is still responsive to commands (though slowly). The site uses DHTML to draw a menu on the left side of the page: "Equipment", "Rate Plans", etc. This menu does not load in Mozilla. The allotted space is blank. I will attach a reduced testcase below. The external JS files in use at the site are: http://www.attws.com/mobileinternet/include/global.js http://www.attws.com/mobileinternet/include/new_menu.js http://www.attws.com/mobileinternet/include/mi_home.js For some reason, the view-source: protocol does not allow me to see these files in any browser. I can see them in the Mozilla JavaScript Debugger. There, the mi_home.js file states it is based on the DHMTL tool "AllWebMenus v2.0"
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached file Reduced HTML testcase
Test case appears to peg the CPU, albeit at 80% or so. There's still some idle time left, but pegging it like that can't be good. :-)
When I load the reduced testcase in NN4.7 or IE6, I get that little DHTML menu in the upper left. In Mozilla, this menu doesn't load. The throbber stops throbbing, but no menu appears. This is the same problem that occurs at the given URL. When I load the testcase off the Bugzilla server (i.e. not locally), my CPU is at 100% non-stop. I get no errors in the JavaScript Console. Will try interrupting a debug build to get a stack trace. The JS is output from the AllWebMenus tool, and is obfuscated: it appears with few carriage returns and opaque function names. Here are a couple functions that I've formatted: function awmCreateMenu (cll,swn,swr,mh,ud,sa,mvb,dft,crn,dx,dy,ss, ct,cs,ts,tn,ttt,ti,tia,dbi,ew,eh,jcoo,jcoc) { if (awmmo>=0) awmmo++; else { awmm=new Array(); awmmo=0 } var me={ ind:awmmo, nm:awmMenuName, cn:new Array(), fl:!awmsc[cs].pos, cll:cll, mvb:mvb, dft:dft, crn:crn, dx:(ct<2)?dx:0, dy:dy, ss:ss, sht:"<STYLE>"+awmsht+"</STYLE>", rep:0,mio:0, st:awmOptimize?2:3, addSubmenu:awmas, ght:awmmght, whtd:awmmwhttd, buildMenu:awmbmm, <<<----- (I printed out this function below) cm:awmmcm }; me.pm=me; me.addSubmenu(ct,swn,swr,mh,ud,sa,1,cs,ts,tn,ttt,ti,tia,dbi,ew,eh,jcoo,jcoc); me.cn[0].pi=null; if (mvb) document.onmousemove=awmotmm; awmm[awmmo]=me; awmsht=""; return me.cn[0]; } function awmbmm() { document.onmousedown = awmodmd; status = "AllWebMenus: Building Menu #" + (this.ind + 1); this.ght(); this.whtd(); awmdb(this.ind); status = awmDefaultStatusbarText; awmdid = setInterval("awmd()", 100); awmsoo = awmso + 1; } Notice the use of setInterval(); perhaps this plays a role in the CPU usage - (?)
The farthest my stack traces ever get are nsAppShell::Run Reassigning to Embedding:Docshell for help on this. NOTE: I don't seem to have CPU problems on Linux or Mac9.1, only WinNT. The DHTML menu doesn't load, but I don't seem to see such high CPU usage. Can anyone else confirm this? NOTE: same behavior for the home site of the "AllWebMenus" DHTML menu builder, http://www.likno.com/ . Mozilla doesn't load the DHTML menu into the blue area to the left of the page on any platform; and on Windows (only?) the CPU goes to 100%.
Assignee: rogerl → adamlock
Component: JavaScript Engine → Embedding: Docshell
QA Contact: pschwartau → adamlock
The mi_home.js has some complicated code at the top that document.write's a <script> tag to include this js: http://www.attws.com/include/menus/awmData-mi_home/awmlib2.js This file is pretty obfuscated but contains a lot of setTimeouts calls. One in particular looks a likely culprit - awmdb() is called from awmbmm() which is called awmCreateMenu() which is called during page loading. The source of this methods is as follows: function awmdb(mi) { var crc=awmm[mi].cn[0]; if (document.getElementById(crc.id).offsetWidth>0) { if (!awmm[mi].cll) crc.show(1); } else setTimeout("awmdb("+mi+")",0); } Notice that it calls setTimeout with a duration of 0 which results in it being repeatedly called. My guess is our setTimeout implementation in nsGlobalWindow should put a limit on how short the delay may be so that silly JS that specifies tiny values, e.g. 0, 3, 5 etc. actually results in a larger interval (e.g. 10ms) to stop the CPU being pegged. Reassigning to DOM on that basis.
Assignee: adamlock → jst
Component: Embedding: Docshell → DOM Core
QA Contact: adamlock → stummala
Attached file Simple testcase
This simple test case has foo() calling setTimeout("foo()", 0).
Adam: thanks. Perhaps this bug is therefore a dupe of bug 123273: "setTimeout(something, 0) causes 100% CPU constant" Note: if the "AllWebMenus" template for DHTML menus becomes a popular tool, lots of sites will have this problem -
Marking it a dupe *** This bug has been marked as a duplicate of 123273 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
marking verified
Status: RESOLVED → VERIFIED
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: