Closed Bug 715918 Opened 13 years ago Closed 8 years ago

Too many javascript events freezes browser (exponential setTimeout/setInterval growth)

Categories

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

11 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mcmanus, Unassigned)

References

Details

JS that creates lots of events (in the case below an ever increasing set of events) can almost completely freeze the UI - so much so that you can't even close the tab. The runaway script dialog never comes up - killing the browser is pretty much the only path. Some sort of runaway detection would be desirable.

2 examples:

function f() {
    for (var i = 0; i < 32; ++i) setTimeout(f);
}
setTimeout(f);

and (derived from a real bug):

function chatRoomClass(){};
var reconnection;
var ctr = 32;

iv=function ()
{
    cr.ws.close();
    for(j=0;j<ctr;j++)
	cr.initws();
}

chatRoomClass.prototype.initws=function()
{
    self=this;
    if("WebSocket"in window)
    {
	if(this.ws!=null)
        {
            this.ws.close();
        }

	this.ws=new WebSocket("ws://doesntreallyexist.tv:88/1");
	var self=this;
	reconnection=setInterval(function(){;clearInterval(reconnection); 
					    iv();}, 1);
    }
};

cr = new chatRoomClass();
cr.initws();
Component: XPConnect → DOM
QA Contact: xpconnect → general
Summary: Too many javascript events freezes browser → Too many javascript events freezes browser (exponential setTimeout/setInterval growth)
No longer depends on: 1300118
I believe this should be fixed now that bug 1300659 has landed.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.