View Full Version : Race condition in Ext.Log?
mankz
29 Dec 2008, 2:52 PM
I wanted to log all events fired in a particular situation for debugging purposes, using my code I got "Out of stack space" in IE. Pretty sure there's a race condition in the Ext.Log code. After adding a defer (as seen below) it works like a charm.
if (!window.console)
{
console = {
log: Ext.log,
dir: Ext.dump
}
}
Ext.override ( Ext.util.Observable, {
fireEvent : Ext.util.Observable.prototype.fireEvent.createSequence(function() {
//console.log(arguments); THIS DOES NOT WORK IN IE
console.log.defer(10, console, arguments);
})
});
To test, use this code on any page with a couple of widgets etc, uncomment the commented line.
Animal
30 Dec 2008, 1:00 AM
console.log.defer(arguments) doesn't work?
The correct way to call defer is as you call it on the line below.
Condor
30 Dec 2008, 1:44 AM
I don't think it's a race condition. It's simply that the Ext debug console is build up of components which also fire events when you log something (which will cause an infinite loop if you attach logging to all events).
How about:
if(!window.console){
console = {
log: function(){
if(!console.locked){
console.locked = true;
Ext.log.apply(Ext, arguments);
delete console.locked;
}
},
dir: function(){
if(!console.locked){
console.locked = true;
Ext.dump.apply(Ext, arguments);
delete console.locked;
}
}
}
}
mankz
30 Dec 2008, 7:47 AM
@Animal: Typo, sorry :). Updated post
@Condor: I think the Logging Panel isn't finished creating itself completely before the next event is sent by the actual component being created. Hence the condition below is always false, unless we add a defer which allows the console to created completely on the first run. I'll test your code later today, thanks! :)
Ext.apply(Ext, {
log : function(){
if(!cp){
createConsole();
}
cp.logView.log.apply(cp.logView, arguments);
},
Condor
30 Dec 2008, 8:01 AM
Are you using this outside of Ext.onReady? Ext.log renders to the DOM, so you can only use it after the document is ready.
Try (untested):
if(!window.console){
console = {
log: function(){
if(Ext.isReady){
Ext.log.apply(Ext, arguments);
}else{
Ext.onReady(Ext.log.createDelegate(Ext, arguments));
}
},
dir: function(){
if(Ext.isReady){
Ext.dump.apply(Ext, arguments);
}else{
Ext.onReady(Ext.dump.createDelegate(Ext, arguments));
}
}
}
}
mankz
30 Dec 2008, 12:46 PM
No it's not doing any logging prior to Ext.onReady. The code in your first post works, thanks :)
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.