Open Bug 141801 Opened 23 years ago Updated 3 years ago

Performance problem with JavaScript-animated background

Categories

(Core :: Layout, defect, P3)

x86
Linux
defect

Tracking

()

Future

People

(Reporter: cesarb, Unassigned)

References

()

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9+) Gecko/20020426 BuildID: 2002042610 Opening the page makes the X server use about 70% of CPU while Mozilla uses about 30% CPU. Closing the page makes everything go back to normal. This seems to be caused by the animated background. Looking at the code, it seems to use document.body.style.backgroundPosition to move the background in a tight setTimeout() loop -- with the timeout set to zero. (the function they use is called moveback()). Reproducible: Always Steps to Reproduce: 1. Start top in a xterm 2. Open the page Actual Results: The X server uses 70% while Mozilla uses 30%. This happens even with Mozilla not visible (the percentages probably change when it's visible). Everything slows a bit (the computer "feels" half the speed for me) since X is niced to -10. Expected Results: No slowdown. Only a bit more CPU usage. No extra CPU usage when the tab or the window isn't visible. The problem seems to be the moving of the background in a setTimeout("",0) loop. Mozilla shouldn't update the screen more than X times per second (configurable), since after some point extra updates per second aren't noticeable anymore.
If setTimeout("",0) is the problem, see bug 123273
sounds like a dup of other "painting when not visible" bugs....
re comment 1: This is not bug 123273, since it's X that's eating most of the CPU, not Mozilla (which just grabs the remaining 30%). re comment 2: Nope, since the CPU usage is high even if it's visible. That's the problem here. The "even when not visible" part will be fixed by these other bugs...
Keywords: perf
Changing QA Contact
QA Contact: petersen → moied
confirmed using branch build 20020509 on linux
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Target Milestone: --- → Future
Cesar, we peg the timeout at at least 10ms now. Any delay much higher than this _would_ be noticeable by people, so we can't really just drop paints on the floor... In any case, the testcase uses about 40% CPU for Mozilla and 0% for X here. A profile shows us spending most of our time in style reresolution, which makes sense. Could you possibly retest with a recent build and let me know how it acts on your end?
Changing URL to point to Internet Archive copy of original page; the page has changed since, and the current page does not show the problem.
Copy of my answer to an email query: > <https://bugzilla.mozilla.org/show_bug.cgi?id=141801> > > Cesar, > do you still see the problem using current version of the product? Yes, I still do (with "Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.8.1.1) Gecko/20060601 Firefox/2.0.0.1 (Ubuntu-edgy)" now). However, I had to get an old version of the page from the Internet Archive; the page has changed too much since. I updated the URL in the bug report to point to the archived copy of the page, and will see if I can make a reduced testcase.
For what it's worth, a profile with a current build shows us spending half our time in cairo painting slowness (text and underlines) and half our time reresolving style on everything on the page (since the body's style context is changing).
It would still be good to have a testcase attached directly to the bug.
Attached file Reduced testcase (obsolete) —
Reduced testcase; removed all external dependencies.
Should reprofile once new textframe lands.
Depends on: 367177
Assignee: attinasi → nobody
QA Contact: moied → layout
Reduced testcase still uses a full single core of my CPU, using lastest nightly (Gecko/20110114 Firefox/4.0b10pre). IE8 and Chrome 8 have the same problem, at least.
Over here it's using about 50% of CPU. Until I put it in a background tab; then it goes down to 20 (thanks to refresh driver throttling). Imo, this bug is basically fixed as filed....
Something got broken in Firefox or it got super fast on this testcase? Because it uses 0% of CPU and Chrome uses almost 100% of all cores. This is super fixed, I think.
It's possible that DLBI affected this testcase.
I'm using Firefox 16 (beta)
Attached file Corrected testcase
Testcase is invalid as it did not specify the css units; chrome let "N N" be equivalent to "Npx Npx". Corrected. Note that referencing a non-existent background object in a setTimeout(...,0) loop may not be a good test... If you save and add a background.gif file, FF and Chrome both get very busy... The settimeout lower limit is in play here.
Attachment #253861 - Attachment is obsolete: true
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: