PDA

View Full Version : [OPEN] [2.0a1][CLOSED] Safari maximum call stack size exceeded on tree traversal algorithms



zakovyrya
4 Oct 2007, 5:49 PM
Due to limitations of Safari Javascript engine tree traversal algorithms (at least 'cascade' which is actually dfs implemented using functions recursion) fall short on complex data structures. I propose things like


cascade : function(fn, scope, args){
if(fn.call(scope || this, args || this) !== false){
var cs = this.childNodes;
for(var i = 0, len = cs.length; i < len; i++) {
cs[i].cascade(fn, scope, args);
}
}
},

replace with something like that


bfsTraverse: function(callback) {
var queue = [ this ];
while (queue.length != 0) {
var node = queue.shift();
callback(node);
queue.push.apply(queue, node.childNodes);
}
},
dfsTraverse: function(callback) {
var stack = [ this ];
while (stack.length != 0) {
var node = stack.shift();
callback(node);
stack.unshift.apply(stack, node.childNodes);
}
}

Sorry, I didn't implement full scope and arguments functionality

mystix
4 Oct 2007, 7:01 PM
pls see 13985 before posting in Bugs. thanks.

jack.slocum
5 Oct 2007, 2:25 AM
Those functions work fine in Safari. I use them all the time. There is nothing spectacularly complex about them. The code you post is most more expensive than interating some nodes and calling a function on each. Or am I missing something?

Take a look at http://extjs.com/deploy/dev/docs in Safari and use the tree search on the left. It is executing cascade frequently without issue.

zakovyrya
9 Oct 2007, 12:57 PM
Sorry it took me so long to answer. I encountered this problem while processing trees more than 15 levels deep

jerrybrown5
15 Oct 2007, 11:05 PM
I also get that error on Safari 3.03 Windows and Ext2.0b. I get it here when running a form approx 5 container levels deep.

initComponent : function(){
Ext.BoxComponent.superclass.initComponent.call(this); <<the line it dies
this.addEvents({

resize : true,

move : true
});
},


After reviewing it more it seems that this is going to be a difficult bug to fix. Apparently, the safari stack size is limited to a mere 100 entries, which is not quite ready for primetime.

http://novemberborn.net/javascript/callstack-size

jsakalos
18 Oct 2007, 5:22 PM
You may also file this as bug or feature request for Safari team. It's still beta so maybe they'll lift this low limit in final version.

jerrybrown5
23 Oct 2007, 8:23 AM
Of course I posted this bug with Safari. :) However, it makes you wonder if they are purposely dumbing down Safari Windows so that it will mimic the behavior of Safari for the limited h/w of the IPhone .

jerrybrown5
18 Mar 2008, 1:20 PM
Woohoo! The stack size of Safari 3.1B/Win is now 500, which is up from 100. Download your copy now and remove those needless setTimeout work around calls.

brian.moeskau
18 Mar 2008, 8:29 PM
Thanks for the info Jerry. I'm marking this thread closed since no Ext action will be taken.