PDA

View Full Version : Invisible screen possibly due to infinite loop with startInterval



M Mello
9 Sep 2009, 2:40 PM
Hello,

I'm new to ExtJS (and JS), and have been handed a misbehaving ExtJS 1.1.1 application. It only works in IE 6/7/8, and is misbehaving in IE 7/8 only (hint?). I have been using QuickTest Pro and IE Developer Tools to debug it.

The app dynamically creates and loads pieces for a webpage from extJS (and homemade) parts, then makes the page visible using an onload() event. It has frames, iframes, tons of DIVs, etc.

However, once in about 100 times, the page doesn't become visible. I see no JS errors (or at least the debugger doesn't tell me about them), and QTP tells me that the objects that I am looking for on the page are actually there. This tells me that the only thing left to occur is the "make visible" command. (But, where did my thread go? Oh, here it is ...)

The other thing I noticed was that when this problem occurs (and only when this problem occurs), there is a thread running forever in extJS code. I can pause it in the developer tools debugger, and it is always in the startInterval() of yui-utilities.js. I noticed that in a few minutes it ran 3500 times, yet nothing changed on the page. Sounds like an infinite loop to me!

However, that thread doesn't seem to have a stack trace (probably due to being called by setInterval()?), and so I can't tell what method it was called from.

Any ideas?

Anybody know what startInterval() is used for?

I actually think this is caused by some kind of race condition. I notice that sometimes some "parts" of this app are not loaded when the app thinks they should be. However, it is really hard to debug when it only happens once in a 100 clicks.

Thanks so much for any help. I have been working on this issue for the last week and am running out of ideas!

-- Matt

toconnor
11 Sep 2009, 9:20 AM
I am seeing this same scenario in Ext 3.0. Just found this thread while looking for a solution.

EDIT: I opened a thread on the premium forum pointing back to this.

M Mello
11 Sep 2009, 10:40 AM
toconnor,

I don't feel "honest" about copying my post from here to the 3.0 forum, as I haven't actually tried it myself under 3.0.

Maybe you can post your issue under 3.0 and update this issue if you get a solution?

--

Also, I think I may have found part of the issue. I have a page loading into an iframe (or frame, I can't remember which), and it has 4 functions called in the _body_ onload event. e.g. onload="func1();func2();func3();func4();"

However, one of the functions does not have a try/catch in it, and it looks like it might occasionally (cause yet to be determined) throw an exception due to "access denied" or "null". When that happens, the other functions do not get called, and func3() turns out to be the one that is making the generated page visible.

I have found 5 different instances in our codebase of more than one function called from onload events. I am in the process of pulling those out into new functions, so that the onload only calls ONE function, which I can then debug effectively.

More info as this progresses. I'm hoping it will help me find the problem easier.

-- Matt

toconnor
11 Sep 2009, 11:06 AM
Here is my post: http://www.extjs.com/forum/showthread.php?p=385825

It doesn't look like the proposed solution will fit nicely in 1.1.

M Mello
11 Sep 2009, 2:32 PM
Thanks, toconner.

From what I can tell, I was able to plugin that js file and get it to work in 1.1.1.

However, while it may occur less frequently, I'm still getting the problem. :(

M Mello
15 Sep 2009, 3:01 PM
The essence of the “fix” is to change this:
<body onload=”func1();func2();func3();…funcN();” … >
to this:
<head>
. . .
Function doOnLoad() {
func1();
func2();
func3();

funcN();
}
. . .
</head>

<body … > <!-- Note no onload() -->

. . .
</body>
setTimeout(‘doOnLoad()’, 100);

</html>


At least, that appears to work so far ... still testing.