One unresponsive JS thread freezes the whole browser

The place to report Pale Moon specific bugs on the Windows operating system.

Moderator: satrow

User avatar
Agent Orange
Moon lover
Moon lover
Posts: 86
Joined: Fri, 17 Apr 2015, 17:13
Location: Linux
Contact:

One unresponsive JS thread freezes the whole browser

Unread postby Agent Orange » Mon, 12 Dec 2016, 15:33

When running any page which has a piece of poorly written JavaScript on it, the entire browser locks up: all tabs across all windows; every aspect of the browser and UI becomes unresponsive, taking tens of seconds to process a single click. Other tabs can neither be opened nor viewed, the offending tab cannot be closed, and even the "stop script" dialog, when it appears, is not readily usable. The CPU usage is only 1 thread @100%, not even enough to kick on the fans.
(Facebook triggers this bug semi-regularly.)

It is unacceptable that a single malfunctioning webpage should be able to wreck the browser so heavily. Chrome does not do this; and even Firefox (50.0.2), while a rogue JS thread does choke its renderer, it does not lock up the core browser and UI; consequently, its "Stop Script" dialog works quickly and as intended.

  • CPU: i7-920
  • Pale Moon 27.0.2 (x64)
  • OS: Mint 18 XFCE
(Will provide any further configuration details requested.)

This code snippet can reproduce the bug reliably: https://studio.code.org/c/301123500/
    ~0x4657BFB0

User avatar
Tomaso
Keeps coming back
Keeps coming back
Posts: 944
Joined: Thu, 23 Jul 2015, 16:09
Location: Norway

Re: One unresponsive JS thread freezes the whole browser

Unread postby Tomaso » Mon, 12 Dec 2016, 15:56

Tested and confirmed.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21960
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: One unresponsive JS thread freezes the whole browser

Unread postby Moonchild » Mon, 12 Dec 2016, 20:17

When running any page which has a piece of poorly written JavaScript on it, the entire browser locks up: all tabs across all windows; every aspect of the browser and UI becomes unresponsive, taking tens of seconds to process a single click. Other tabs can neither be opened nor viewed, the offending tab cannot be closed, and even the "stop script" dialog, when it appears, is not readily usable. The CPU usage is only 1 thread @100%, not even enough to kick on the fans.

The "stop script" dialog should suspend the offending script, unless you're looking at poorly written JS that causes issues due to recursive calls (e.g. a timeout calling itself). There's no easy or reliable way to safeguard against this kind of thing, since it will flood the main thread (which is by its very nature a 1-core deal; the controller thread can't be multithreaded).

That being said, I can see if I can make the "stop script" function a bit more aggressive in what all it stops.

EDIT: it seems reasonable to me to just stop all scripts in a tab if you hit the unresponsive script dialog. That will be a simple, effective fix.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21960
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: One unresponsive JS thread freezes the whole browser

Unread postby Moonchild » Mon, 12 Dec 2016, 22:45

https://github.com/MoonchildProductions ... 4ebaa09780 takes care of this -- do note that really bad recursive scripting will continue to hang the browser, but at least "stop script" gives a better way out in this case.
Added a pref dom.global_stop_unresponsive_script (boolean) to control this behavior in case you want the old way, although I can't off-hand think of a situation where you'd just want to stop one script -- you're likely going to have a (very) broken situation anyway :?:
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

User avatar
Agent Orange
Moon lover
Moon lover
Posts: 86
Joined: Fri, 17 Apr 2015, 17:13
Location: Linux
Contact:

Re: One unresponsive JS thread freezes the whole browser

Unread postby Agent Orange » Tue, 13 Dec 2016, 03:11

Moonchild wrote:[…]There's no easy or reliable way to safeguard against this kind of thing, since it will flood the main thread (which is by its very nature a 1-core deal; the controller thread can't be multithreaded).
Why is this? Is it truly necessary for an out-of-control script to lock up the browser's user interface? Why do Firefox and Chrome not have this behavior? Are there any "pages available to be stolen from their book", so to speak?

Moonchild wrote:That being said, I can see if I can make the "stop script" function a bit more aggressive in what all it stops.

EDIT: it seems reasonable to me to just stop all scripts in a tab if you hit the unresponsive script dialog. That will be a simple, effective fix.
That like a workaround to an issue separate from the one that this thread is about.

The stop script dialog DOES work; it just takes an eternity for the browser to get around acknowledging that the button was pressed…
    ~0x4657BFB0

User avatar
Agent Orange
Moon lover
Moon lover
Posts: 86
Joined: Fri, 17 Apr 2015, 17:13
Location: Linux
Contact:

Re: One unresponsive JS thread freezes the whole browser

Unread postby Agent Orange » Tue, 13 Dec 2016, 16:40

Agent Orange wrote:[…]That like a workaround to[…]

Argh, what a horrible typo! And I can't edit it!! :oops:
    ~0x4657BFB0


Return to “Bug reports (Windows)”

Who is online

Users browsing this forum: No registered users and 1 guest