搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Is it possible to put a hard limit on how much CPU is used by JavaScript execution?

  • 3 个回答
  • 7 人有此问题
  • 3 次查看
  • 最后回复者为 castrwilliam

more options

Even today, there are tons of Web pages with JavaScripts on them that seem to peg the CPU usage. Usually, the browser will completely freeze for a while (15 seconds, and it won't respond to clicks whatsoever - the only thing possible during that time is to terminate or kill it). It will always recover from said hang. About 30-40% of the time, there will be a dialog that offers to stop execution of the script.

It has a checkbox that says "don't ask me again", which I checked... but it seems that Firefox takes that as "don't terminate scripts ever", not "whenever this dialog box is about to be displayed, take this marked check as my implicit approval to halt the script without asking."

I'm not completely sure if it's something to do with the engine itself, the pages, or something else, but I'm wondering if such an option exists.

Even today, there are tons of Web pages with JavaScripts on them that seem to peg the CPU usage. Usually, the browser will completely freeze for a while (15 seconds, and it won't respond to clicks whatsoever - the only thing possible during that time is to terminate or kill it). It will always recover from said hang. About 30-40% of the time, there will be a dialog that offers to stop execution of the script. It has a checkbox that says "don't ask me again", which I checked... but it seems that Firefox takes that as "don't terminate scripts ever", not "whenever this dialog box is about to be displayed, take this marked check as my implicit approval to halt the script without asking." I'm not completely sure if it's something to do with the engine itself, the pages, or something else, but I'm wondering if such an option exists.

所有回复 (3)

more options

Hi castrwilliam, I do not know in the user interface, but all of the ways that these are controlled can be played with

  1. In the Location bar, type about:config and press Enter. The about:config "This might void your warranty!" warning page may appear.
  2. Click I'll be careful, I promise!, to continue to the about:config page.
  3. Search for javascript
more options

Start Firefox in Safe Mode to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).

  • Do NOT click the Reset button on the Safe Mode start window.
more options

I already looked in about:config. Nothing there seems to be of useful here. All that the options there mention is memory management. There's a "javascript.options.mem_notify", which sounded vague enough to maybe also control that, but apparently it's there to help developers optimize add-ons: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/GC/Statistics_API

I just relaunched in safe mode this morning and nothing seems to be acting up yet. The problem was intermittent so I'm not going to say that fixed it completely, but it's a definite improvement.

由castrwilliam于修改