7

Solved! Waffles had kindly changed the script that checks how many letters you've typed in the comments: now I don't have any lag any more (at least none out of the ordinary on this oldish PC). Bravo! Watch my typing.


Updated: here is a screencast of my typing I am testing the speed of typing in this comment., on Firefox 5, on this Pentium IV @ ~2GHz, Windows 7. You can see how many letters vanish and how slow it is. Pay attention to the sound of my typing: I was finished typing half way through the recording, but the letters weren't quite there yet...

Updated again: Here is another screencast, with Firefox in safe mode (Help -> Restart with Add-ons Disabled), which disables all add-ons, settings, etc. Not much better. I also tried a virgin profile on FF 3.6 at the time (see below), just as bad. A mysterious issue.


When I type something in a comment on Superuser.com or English.stackexchange.com, typing lags badly. I see the letters slowly appearing one by one on the screen, sometimes two seconds or longer after I actually pressed the keys. Often it even fails to register key presses when I go too fast, or it wrongly puts the first letter after the second, even though I typed them in the right order. What can this be, and how could I fix it? It is driving me crazy.

  • This happens on those two sites, not on any other random forum or web form. I have typed in all kinds of different sites since I joined the SE/Superuser etc. family, but it has only been happening there. So I think it must be specific for the SE family.

  • It is very bad when typing comments, but usually much better in answers and questions.

  • When my text is auto-saved, I get a particularly horrible lag with missing and misplaced letters.

  • It happens on two different computers, both around 2 GHz single core (at least one has hyperthreading), but both with plenty of RAM, each with a different keyboard, monitor and all.

  • One PC is on XP Home, the other on Win 7 (fresh install), both with equally bad lag; but the lag does not happen, or is hardly noticeable, on my third PC with dual-core 3 GHz, 4 GB RAM, XP Pro SP3. All three PCs are 32-bit.

  • The bad lag happens on Firefox 3.6.13 and Internet Explorer 8.0. It is slightly noticeable on Chrome, but much, much better, not really a problem; for example, when I backspace a long word, it goes a bit slowly and choppy, but with normal typing it is hardly noticeable.

  • I have plenty of memory available when it happens, only 600 of 1500 MB are in use on this PC.

  • I see no spikes whatsoever when in happens, neither in CPU use nor in memory or disk usage.

  • I have shut down the only 3rd-party program that I had running on both PCs (StrokeIt, mouse gestures), but that didn't help at all.

[Edit]

  • I just noticed that the bug seems absent from a fourth PC, my old 1.5 GHz laptop with Win XP SP3 32-bit and 500 MB RAM. I have only tried it on Firefox there.

  • The slowness tends to get even worse as I have Firefox open for a longer time.

I'd be so happy if this could be solved! Or if there'd be a setting to make comments work without javascript, if that is even possible.

6
  • @JefAtwood: Well, it is still an issue. I will post a video. Updating to Firefox 5 helped only a little: it is still much worse in FF than in Chrome... Commented Jul 1, 2011 at 2:48
  • @Jeff: I have posted a screencast where you can see what happens. It is just as bad on Firefox 5 as it used to be on 3.6... very strange issue. The fact that it is the same on two computers would seem to indicate that it could be happening to more people. By the way, it is not as bad on all sites: I am typing here with lag and disappearing letters, but it is still somewhat workable. But if I type reasonably fast on English.se, its meta, on Superuser, Philosophy, etc, it is quite catastrophic (see screencast above). Commented Jul 4, 2011 at 1:55
  • Apparently there are video sites that require Java still
    – random
    Commented Jul 4, 2011 at 2:17
  • @Random: Yeah I noticed, so I uploaded it to Youtube instead (edited link). Thanks for watching! Commented Jul 4, 2011 at 2:28
  • The Pentium 4 2.0 Ghz is almost 10 years old; it was introduced in Q1 2002. What are the specs on the other PC that had issues? (mind you, I agree that a silly javascript character counter should not be causing perf issues, but...) Commented Jul 4, 2011 at 8:06
  • @Jeff: I was inaccurate: one P4 is 2.6 GHz, the other 2.2GHz. They had the same issue, which, thankfully, is now a thing of the past! My laptop with a similarly old P4 seemed to have much less lag when I tested it at the time. Thanks for looking into this. Waffle solved it brilliantly; I should have made a screencast sooner. Commented Jul 4, 2011 at 17:26

2 Answers 2

3

I just changed the way we count the chars left. (which is the reason for the lag) ... eg: "10 chars remaining" notice.

We used to handle the keyup blur and focus events inline calculating the chars remaining before allowing you to enter any more keystrokes. It had a couple of minor issues where it was not caching selectors.

Now, I fire off a timer waiting 100ms before calculating the chars remaining. This means that we may only ever run this 10 times a second.

I profiled the page and noticed that, just like twitter, most of the time is being spent in jQuery dispatching these events.


There are only 2 more things we could possibly do to speed this up any more:

  1. Write custom event dispatch code, which is not going to happen.
  2. Slow down the responsiveness of the counter, and cancel timers if a new one is added to the queue. I do not really want to go there.
4
  • Thank you! Really cool of you to look into this. When do you think this will go live on English.se and Superuser? I will test it tomorrow, can't wait! Commented Jul 4, 2011 at 5:58
  • @Cerberus, can you try now (just in case clear your cache- should not be needed)
    – waffles
    Commented Jul 4, 2011 at 7:36
  • 1
    Wow!! This is absolutely perfect! I just tried commenting on English.se and Superuser, and I hardly experienced any lag at all. No weird white flickering, no letter eating. Now they are just as fast as text-input fields on any other website for me. I cannot thank you enough! Commented Jul 4, 2011 at 7:55
  • awesome ... very happy to hear!
    – waffles
    Commented Jul 4, 2011 at 8:03
2

Most likely cause is that you are using older versions of Firefox and IE which have significantly slower javascript engines than the version of Chrome you are using.

8
  • 1
    Thank you for your answer! But I forgot to mention that I am using FF 3.6.13, and IE 8.0.
    – Cerberus
    Commented Jan 21, 2011 at 2:39
  • 1
    I had similar issues with Firefox 4.0 beta; stable 3.6.13 version works OK.
    – ulidtko
    Commented Jan 21, 2011 at 8:02
  • Try running a javascript benchmark in each of the browsers and see if the ones you are having trouble with clock in slower.
    – Swiss
    Commented Jan 21, 2011 at 8:11
  • @Ulidtko: Okay, that is interesting. So did you test it on other browsers as well? And what kind of CPU do you have? Commented Jan 21, 2011 at 15:39
  • @Swiss: Thank you, good idea! I have run Javascript benchmark tests ( www2.webkit.org/perf/sunspider-0.9.1/sunspider-0.9.1/… ), and indeed Chrome was the fastest @ 1400 ms, FF @ 2400 ms, and IE... @ 11,000 ms. I also noticed that CPU usage in the test correlated to speed: in Chrome, it was around 95% all the time; in FF, 65%; in IE, 55%. Any idea how I could make it better on FF? I miss my add-ons. And I wonder why there is hardly any CPU usage when my slow typing in FF/IE occurs. Commented Jan 21, 2011 at 15:45
  • I have tried it on Firefox 5, and it is just as bad.... very strange issue. Commented Jul 4, 2011 at 1:56
  • 1
    @cerb is this in Firefox 5 safe mode? I want to confirm that NO extensions are active, as we've seen tons of problems with rogue and poorly written Firefox extensions. This is important. Commented Jul 4, 2011 at 2:35
  • 1
    @Jeff: Thanks for watching. That screencast wasn't in safe mode, but I have made a new one in safe mode, which is, alas, not much better (see link above). I had already tried it with FF 3.6 on a virgin profile, with the same result. A very strange issue... Commented Jul 4, 2011 at 2:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .