STEAM GROUP
TF2B Developer Group TF2B
STEAM GROUP
TF2B Developer Group TF2B
70
IN-GAME
564
ONLINE
Founded
13 April, 2010
All Discussions > Bug Reports > Topic Details
hirsute 23 Sep, 2012 @ 5:11pm
bug : autorefresh function goes crazy and refreshes constantly
There is a bug with the autorefresh, which ultimately results in the browser refreshing the backpack continuously, refreshing the page as soon as the previous one finished loading. This isn't immediate, it takes some time to build up.

Steps to reproduce : (only tested on firefox 15, ffx 10 ESR & ffx 3)
  • Open a backpack on tf2b
  • go to "menu"; click "Disable Autorefresh"
  • Open another backpack (or just F5 the current one)
  • Wait one to two hours...
  • More seriously : open firefox's web console (tools => Web developer => Web Console and watch the timestamps on the ajax calls. You'll get one after 10 minutes. But 10 minutes later ? 2 loads of the stripped page. 10 more minutes and that will be 4 calls.
  • An hour after your last manual page load that will be 32 refreshes in a row. Which is enough that you may notice it. After 2 hours, your browser will most probably be continuously refreshing the page because it can't finish its refresh spree in 10 minutes.
  • optional : getting tf2b to behave sanely again on your browser will require you to clean the cookie associated with tf2b.com called "norefresh". In firefox that's Edit => Preferences => Privacy tab => remove specific cookies => filter for tf2b => delete the one called "norefresh"

source of the problem : forgotten parentheses in tf2b.js :
function init() { // [...] snip if(!rtimer||getCookie("norefresh")) rtimer=setInterval(pageUpdate,10*60000); }
related to
<a onclick='clearInterval(rtimer);setCookie("norefresh",1)'>Disable Autorefresh</a>
i.e. : Disabling autorefresh once sets the norefresh cookie, and if that cookie is set then register a new update timer each time init() is called. And init() is called at the end of each successful refresh in pageUpdate().
IOW : a basic time-bomb with exponential growth.

note that if you click "Disable Autorefresh" before the first refresh, it will correctly clear the timer, thus the website is usable if you can remember to always disable autorefresh after each bp load.

If you forget ?

Consequences will vary. On my eeepc the CPU drain of loading a bunch of webpages is very sensible (I pretty much stopped using tf2b before I put my debugging cap on and figured out this thing). On the pc I use to play tf I would notice sudden lag spikes of a few seconds (getting longer and longer until I figured I had forgotten to disable autorefresh in a tf2b tab somewhere). A friend I asked for troubleshooting help had pings to tf2b.com so high (250ms+) the only thing he would notice was the news line changing every second. The final nail in the coffin is a memory leak (closure scopes chains) caused by this mad refresh timer setting; leading to ever increasing browser memory. If I'd forget such a tab in a browser when going to bed, I'd come back to a crashed browser and most other processes heavily swapped.

Thanks for your attention, the otherwise stellar website, and thanks in advance for fixing this.
Last edited by hirsute; 23 Sep, 2012 @ 5:13pm
< >
Showing 1-3 of 3 comments
hirsute 23 Sep, 2012 @ 5:21pm 
Posting in a reply coz that OP was already tall enough.

The basic fix for the bug, adding parentheses where they were obviously intended would have for consequence that anybody who disabled autorefresh once would never ever have it again. (cookie expiration in next century) I often don't want it, but sometime I do, and just as often I don't really care.

My perfect setup would be to have autorefresh off by default and a toggle to activate it on the current page. But I could easily live with a toggle that both sets the current page behavior and the behavior of the next page loads. (Though there's an obvious issue with the current setup where setting a cookie in a just loaded page would affect the behavior in an already loaded page in another tab).

Now, I understand such a feature is really low importance. Obviously very few people care. Coz if they had ever disabled autorefresh you would have noticed your bandwidth/cpu bill is ridiculously higher than expected. I just think that would be nicer.
Last edited by hirsute; 23 Sep, 2012 @ 5:22pm
Athernar~ 23 Sep, 2012 @ 9:51pm 
Ugh, that would explain some things.

What an utterly stupid mistake on my part. Thanks for the detailed report, it's nice to see something more than "fix plz" for a change.

I've pushed a rudimentary change that'll stop the exponential interval declaration. I'll get a rework of that entire section of tf2b.js ASAP. Beyond that I think it's probably about time a rate limiter was implemented.

Message me on Steam and I'll toss you a few refined and a dueling minigame as a thanks.
Last edited by Athernar~; 23 Sep, 2012 @ 10:01pm
hirsute 24 Sep, 2012 @ 2:04pm 
Ah. So you had noticed your resource consumption was not normal.
Well, you're welcome. I'm glad to have helped.
< >
Showing 1-3 of 3 comments
Per page: 1530 50

All Discussions > Bug Reports > Topic Details