High Constant CPU Usage - Modified Gmail Macros (infinite loop)

11 views
Skip to first unread message

Edward Lee

unread,
Nov 6, 2008, 12:01:13 PM11/6/08
to gmail-po...@googlegroups.com
Modified Gmail Macros v. 2.0 sits at a constant 40% CPU for me because
it keeps trying to look for gmailapi on frames that won't happen. In a
couple frames, it does load correctly, but in others, it just keeps
doing:

if (gmailapi == null) setTimeout(arguments.callee, 0);

I've attached a patch to stop trying after 10 seconds.

Ed

# HG changeset patch
# User Edward Lee <edwar...@engineering.uiuc.edu>
# Date 1225665277 21600
# Node ID 14ba2fec441cc7d1e1abffe3f7f15644247f3976
# Parent 091fb3f6a3950923c0b02ccd7a98678ad6752deb
Avoid high cpu infinite loop by stopping after 10 seconds

diff --git a/modified_gmail_macros_v_.user.js b/modified_gmail_macros_v_.user.js
--- a/modified_gmail_macros_v_.user.js
+++ b/modified_gmail_macros_v_.user.js
@@ -11,12 +11,15 @@
var scriptVersion=20081021.1;

window.addEventListener('load', function() {
+ // Keep trying to load in this frame for 10 seconds
+ var tryLoad = true;
+ setTimeout(function() { tryLoad = false; }, 10000);
+
(function(){
var gmailapi = typeof unsafeWindow != "undefined" &&
unsafeWindow.gmonkey
|| (frames.js ? frames.js.gmonkey : null);
if (gmailapi == null) {
- setTimeout(arguments.callee, 0);
- return;
+ return tryLoad ? setTimeout(arguments.callee, 0) : 0;
}
gmailapi.load('1.0', init);
})();

--
Ed

high.cpu.diff

sewpafly

unread,
Nov 6, 2008, 10:58:29 PM11/6/08
to GMail Power Users
Thanks, I'll incorporate this patch with the next version!

sewpafly

On Nov 6, 9:01 am, "Edward Lee" <edi...@gmail.com> wrote:
> Modified Gmail Macros v. 2.0 sits at a constant 40% CPU for me because
> it keeps trying to look for gmailapi on frames that won't happen. In a
> couple frames, it does load correctly, but in others, it just keeps
> doing:
>
> if (gmailapi == null) setTimeout(arguments.callee, 0);
>
> I've attached a patch to stop trying after 10 seconds.
>
> Ed
>
> # HG changeset patch
> # User Edward Lee <edward....@engineering.uiuc.edu>
>  high.cpu.diff
> 1KViewDownload
Reply all
Reply to author
Forward
0 new messages