# Showstopper bug: MSE+MathJax unusable for 6 months with Chrome

For roughly six months or so, since around the latest MathJax deployment, the site has been highly unstable using recent Chrome versions (17-22) on Windows 7. I see guaranteed page freezes composing answers of nontrivial length, "Aw Snap" browser crashes, etc. I have lost much work while composing answers due to this serious bug. I cannot recall any other software problem in recent memory that has proved more frustrating. The bug seems to be specific to MSE/MathJax since Chrome is rock-solid on all other sites I visit.

I've been waiting patiently for a fix, but it appears that there is none forthcoming (there has been no official response from SE). Could SE folks please give some indication whether or not resources will be allocated to fix this showstopper bug? Given that Chrome is one of the browsers with highest market share (being generally fastest - as it is on MSE), we may end up losing members if the site does not function stably in Chrome.

Is anyone using Chrome 18 not encountering these problems? If so, perhaps as a community we can troubleshoot the problem and devise workarounds.

Update Thanks to zyx for reminding me in the comments that Eric Naslund reported a similar bug March 1 on MSO. Then we both were using Chrome 17, so the bug isn't specific to Chrome 18.

Similar freezes were reported on MO when MathJax 2 was deployed there (March 22). This seems to confirm my hunch that the problems were introduced by MathJax 2.0.

I have added some answers to poll Chrome usage to help determine if the bug is specific to browser or browser+OS or some more specific context. I suspect that the bug may not be widely reported here since the majority of users here may be using Firefox. However, even if so, Chrome is well on its way to gaining leading market share generally (see stats below), so if the site is broken in Chrome, the majority of users who encounter MSE through web search results may have major problems accessing the site.

-
I think the bug is specific to MathJax since it also happens to me on MO. So I think the MathJax people are the right people to complain to, not the SE people. –  Qiaochu Yuan Apr 23 '12 at 15:38
Had you reported this problem elsewhere? (FWIW, I do not see any such problem using Firefox) –  Mariano Suárez-Alvarez Apr 23 '12 at 15:38
No problem. Firefox v.11 (thanks to Jeff Atwood for recommending I upgrade from v. 3!) –  The Chaz 2.0 Apr 23 '12 at 15:41
Yes, this bug has bitten me too. However, I think this issue is specific to chrome. –  user21436 Apr 23 '12 at 15:50
@Qiaochu This is not the same occasional crash that appears in other browsers. Using Chrome 18 one gets a guaranteed freeze if one composes an answer of any nontrivial length. Further, it completely crashes Chrome in some cases. –  Bill Dubuque Apr 23 '12 at 15:52
@BillDubuque, this is the correct place to report it. But since you wrote that you have been waiting a couple of months for the fix I wondered if you had reported this earlier to SE somewhere else: otherwise they might not even be aware of the problem! –  Mariano Suárez-Alvarez Apr 23 '12 at 16:10
I emphatically suggest that next time you or anyone comes across a problem so serious that it can be considered it to be a showstopper bug, you skip the comments step and post it as soon as possible as a question here on meta. I am pretty sure you could have saved a couple of months of having the show stopped that way. –  Mariano Suárez-Alvarez Apr 23 '12 at 16:28
OK. I'll just ignore this thread. –  Mariano Suárez-Alvarez Apr 23 '12 at 16:36
@Mariano It's your prerogative to ignore whatever you like. That doesn't help fix the bug. It's not my responsibility to do bug tracking for SE, nor should moderators be posting silly remarks like the above implying that members should do so. I don't find your above comments very welcoming. –  Bill Dubuque Apr 23 '12 at 16:44
@BillDubuque 1. If Chrome crashes, then there is a bug in Chrome. This doesn't imply that there isn't also a bug in MathJax or in the Stack Exchange code, but Chrome is not supposed to crash whatever a web page throws at it. 2. A Stack Exchange bug report is a question on a Meta site (such as Mathematics Meta) tagged bug. A comment has no bug and so is not a bug report. The oldest bug report about Chrome 18 concerning crashes I can see here is yesterday's. –  Gilles Apr 23 '12 at 23:52
I find it absurd that someone who may have information relevant to a problem s/he wants to have fixed (like relevant reports) at the same time may think that it is better to withhold that information. If there are extant reports on the issue, starting a new thread on the matter only increases the noise and then it should simply be closed. I invest much more than two seconds already on this site: it seems absurd to me that if you or anyone already has the information in question, you do not simply provide it instead of giving dismissive instructions to «type into the search box». –  Mariano Suárez-Alvarez Apr 24 '12 at 1:07
At the moment, I do not see what purpose this thread has, as by at least two accounts there are already several reports on the matter and there have in fact been for months now. Any new reporting of information should happen on those reports: nothing will be gained by scattering the relevant data even more. –  Mariano Suárez-Alvarez Apr 24 '12 at 1:10
@BillDubuque: I am not SE folks, I am MathJax. It is also not true that no work has been done to address this issue. It was originally reported during the MathJax 2.0 beta stage, and after the v2.0 official release at the end of February, I worked on a rewrite of the preview code hoping to resolve this issue (and the delay issue as well). That was not successful in eliminating this issue with Chrome. I have not been able to reproduce it myself, so it is difficult for me to diagnose it. –  Davide Cervone Apr 24 '12 at 12:29
As Gilles points out, "Aw Snap" represents a bug in Chrome regardless of whether it is triggered by something SE or MathJax does. Just because Chrome hasn't crashed for you on other sites doesn't mean it isn't a Chrome bug. The trigger is undoubtedly the heavy javascript/DOM work done during the preview, and it is probably due to some interaction between the preview code, MathJax, and the DOM modifications that are being made. Personally, I think it is because the DOM is being replaced by the editor while MathJax is still working on it, but that is just a guess. –  Davide Cervone Apr 24 '12 at 12:32
@BillDubuque, I respectfully disagree: "Aw Snap" represents a bug no matter what caused it, just as MathJax's "[Math Processing Error]" always represents a bug in MathJax, as they are the results of uncaught exceptions within the code. A freeze is also a bug in my opinion, but that is a bit more ambiguous. In any case, you already have the code, since it is sent to your browser every time you use the site. The code that I wrote is here. Knock yourself out. PS, my name is "Davide" not "David". –  Davide Cervone Apr 24 '12 at 15:54

Yes, I have major problems browsing MSE with Chrome recently.

Please upvote (don't downvote!) this answer if you have made significant use of Chrome to browse the MSE main site in the past couple of months with many freezes or crashes (Aw Snap!). Please add a comment mentioning your OS, Chrome version, and any other contextual information that may prove useful for debugging purposes.

-
system - Windows 7, hint - sometimes text restored sometimes not –  no identity Apr 23 '12 at 23:11
Windows 7, Chrome-18.0.1025.162; "Aw Snap!"s often--No information is saved when I edit. They get saved if I am composing the answer. And, this seems to happen because of the frequent flickering of TeX. –  user21436 Apr 24 '12 at 1:18
Believe it or not, someone downvoted this poll answer. So much for trying to conduct an honest poll. –  Bill Dubuque Apr 24 '12 at 6:15
I feel that they fail to understand what a poll means. There is also a downvote in the previous answer. –  user21436 Apr 24 '12 at 6:27
@Kannappan Perhaps, so I've added "don't downvote". –  Bill Dubuque Apr 24 '12 at 6:32
I don't quite understand the upvotes on the comments. Is that someone saying "me too" for that comment? If so, are they not upvoting the answer? The answer (currently) has two upvotes, but there are a total of four upvotes on the comments, so I'm confused about how many people reporting this problem that represents. –  Davide Cervone Apr 24 '12 at 13:08
@DavideCervone: This answer is +3-1, so I'd say that the 3 upvotes matches up to the 3 comment-upvotes on Kannappan Sampath's comment. –  Isaac Apr 24 '12 at 17:00
@David Please note that this answer has 3 upvotes (someone downvoted it for some strange reason). So, currently, including I, there are at least 4 Chrome users encountering this problem. Since the reports on the alternative are all on Macs, it seems that, so far, everyone using Chrome on Windows 7 encounters the bug, which agrees with my experience on a handful of Windows 7 machines. To reproduce it usually requires an answer of at least a couple paragraphs, with nontrivial MathJax, and some amount of editing. –  Bill Dubuque Apr 24 '12 at 17:09
@Isaac and Bill: Sorry, I can only see the total of 2 — I don't know how to see the ups and downs separately. But in any case, doesn't a 1 upvote mean two people (the original poster and the upvoter) and a 3 mean four people? So the comments have 6 but the answer has only 5 (Bill's answer, plus the 4 votes — 3 up and 1 down, assuming the down vote was meant as an up). It still seems out of whack to me. –  Davide Cervone Apr 24 '12 at 22:44
@David Yes, I mentioned the downvote precisely because I knew that you don't have the rep to see it. There are no votes from me (authors cannot vote on their own posts). I don't know what the comment votes signify. They could be bug reports or not. –  Bill Dubuque Apr 24 '12 at 23:05
chrome 18 is extremely buggy, for the record, not just with MathJax rendering but in lots of other ways I've seen. It's the buggiest release I have encountered in Chrome to date. I actually might recommend switching over to Firefox (or Safari.. maybe even IE9) until they get this worked out. –  Jeff Atwood Apr 26 '12 at 6:56
@Jeff As I said, the freezes/crashes also occur in Chrome 17, released Feb. 8. I'm not aware of any feedback on MathJax 2.0 on earlier Chrome versions, but that might be useful to know for troubleshooting purposes. Why was MJ2 deployed without any (alpha/beta) testing? Many users lost valuable work due to these crashes. This is not a nice way to support members who volunteer many thousands of hours of their time here. Can we expect better support in the future? –  Bill Dubuque Apr 26 '12 at 14:28
Just a note: this used to happen on Phy.SE for me as well. But I use chrome canary, so I get bugs and bugfixes early :) –  Manishearth May 9 '12 at 16:08
Still lots (LOTS) of "Aw Snap" problems here, with Chrome 18.0.1025.168, Win-7. This, together with the other (unrelated?) bug of "Show math -> As text" (also, only with Chrome) is a pain. –  leonbloy May 11 '12 at 17:47
@leonbloy You might want to try the extension mentioned in Davide's answer (I haven't been able to test it yet). –  Bill Dubuque May 11 '12 at 18:23

I am still unable to reproduce the problem that you all are having. I seem to be able to type answers for five minutes of pretty much constant typing in Chrome 18 on Windows 7 with no sign of a crash. I'm wondering if there is some other common factor among those who are experiencing the problem. E.g., some extension, or lots of open tabs, or some optional system component or something.

I still think that the most likely trigger for the problem is that the preview editor can replace the contents of the preview while MathJax is still processing it (meaning MathJax may try to process math that is no longer there). When I rewrote the preview code, I tried to minimize the time that that was possible, but did not eliminate it entirely, so that is still my primary concern.

Other possibilities include memory management problem within Chrome (e.g., reusing memory that has already been freed), or garbage collection problems, or other such issues. The preview/MathJax combination does put a very heavy burden on the browser, and if there are memory problems, that could likely bring them out.

To test my hypothesis concerning the replacement of the preview while MathJax is still running, I have put together a Greasemonkey script that replaces the current MathJax preview code with a modified version that prevents the editor from pulling the DOM out from under MathJax while it is still typesetting. (It does this by making a second copy of the preview, which is the one that MathJax works on, and that is updated only when MathJax is guaranteed to be finished with it. The editor is free to replace the other at any time it sees fit).

If those of you who are experiencing the problem would like to help diagnose it, please install this extension and try out editing to see if that improves the situation or not. It will affect only the math.stackechange.com and meta.math.stackexchange.com sites, and you can tell that this extension is operating if you see that the border of the preview is blue rather than grey.

The userscript actually works in Firefox, Safari (with GreaseKit), and Opera as well as Chrome (I haven't tried it in IE), but the real interest is in whether it fixes the Chrome issue. The timing of when this code runs is critical (since it must intercept the StackExchange code at just the right time in order to install itself properly); unfortunately, the Safari and Opera implementations of userscripts are somewhat variable in the timing of when they run, so it is possible with those browsers that the script misses the window of opportunity and can't install itself correctly. If that happens, reloading the page usually resolves the problem. (Opera pretty much always misses the first time through a page, but works on a reload.)

Please leave a comment here concerning your luck with this extension if you try it out. Remember that this is experimental code, so you may want to disable or remove it once you are done trying it out.

Aside: I am also working on an incremental previewer that only updates the paragraph that you are editing rather than the entire answer. That should help with longer posts with lots of math. This is a much more complicated prospect, however, since you have to get things like references (\label{} and \ref{}) and macro definitions (\def and \newcommand) to work incrementally as well, forcing updates in other parts of the answer when they are needed due to changes in the current paragraph. If this experiment with userscripts goes well, I will make the incremental preview available for testing in a similar way, and then offer it to the StakeExchange folks once any kinks are worked out.

-
Lots of open tabs here, anywere between 30-90 I'd guess. And they can stay open for over a month, with partial drafts of answers. I'm not surprised that it takes some nontrivial context to reproduce since I don't usually see it right away. But once it starts occurring it never stops. I'm not using any extensions. –  Bill Dubuque May 8 '12 at 22:16
Could it possibly be related to running out of some resource when so many tabs are open? E.g. maybe some GC bug (failure to properly reclaim some resource) eventually causes large long-running sessions to run out of the resource, causing MathJax to freeze? –  Bill Dubuque May 8 '12 at 22:24
I knew you used a lot of tabs; I was curious if others did as well. Sure, using so many long-lived tabs certainly can cause problems. If there is a memory management issue (a memory leak for example) that could very well cause you to run out of memory. And if there are memory re-use problems (re-using freed memory), the longer the processes run, and the more of them there are, the more likely that will become a problem. So yes, you are operating in a fashion that is most likely to be adversely affected by those kinds of issues. –  Davide Cervone May 8 '12 at 22:34
The fact that when a problem occurs in one window it affects the results in other windows or other pages in teh same window ("once it starts occurring it never stops") suggests a memory problem. –  Davide Cervone May 8 '12 at 22:38
I'm wondering if you are planning to try the extension that I have offered to see if that helps you out? –  Davide Cervone May 8 '12 at 22:38
Yes, I plan to try it sometime in the next day or two (I can't risk a crash at the moment). Do I need to reboot and/or restart Chrome to properly test it? Ditto for removing it? Thanks much for looking into it. –  Bill Dubuque May 8 '12 at 22:52
You do not need to reboot the computer. Technically, you do not need to restart the browser (but would need to reload any page where you wanted to try it). But if the problem you are having really is a memory issue, then not restarting the browser may mean that the memory problems are still in play, and so would not be a fair test. So I would recommend restarting the browser. You can try it initially without a restart, but having a crash under those circumstances would not seem very conclusive to me. –  Davide Cervone May 8 '12 at 22:55
Ok, that's what I figured. And what about removing it? Does disabling it do the trick or should the browser be restarted to be sure. –  Bill Dubuque May 8 '12 at 22:58
No problem. When removing it, you don't need to reboot. Things should go back to the original editor for any new page you open or old one you reload. –  Davide Cervone May 8 '12 at 23:00
Ok, I'll let you know asap if I can reproduce it with the extension. I don't recall typically how long it took from browser start to reproduce it - could be a day, could be a week. But I'll use Chrome exclusively to try to trigger it asap. –  Bill Dubuque May 8 '12 at 23:05
OK, thanks. I await your results, and those of anyone else who wants to give it a try. –  Davide Cervone May 8 '12 at 23:06
Btw, here's one other data point. Sometimes I restart Chrome from a saved session after a Win7 reboot. This means that it quickly reloads many tabs, often over 100, many with MathJax. Could that be causing problems for MathJax, with many tabs attempting to render simultaneously? Perhaps problems that don't manifest immediately? –  Bill Dubuque May 8 '12 at 23:23
Not that would be causing the crashes that you see. It potentially could cause MathJax to time out waiting for files or fonts since all the instances of MathJax are competing against each other for network bandwidth, and MathJax's timeout times are relatively short (15 seconds). So some copies of MathJax might give up on some files and go on without them, leading to "Math Processing Errors" later on. But you are definitely pushing the limits, I would imagine. –  Davide Cervone May 8 '12 at 23:28
Yes, I do get many such errors, but all seems well after refreshing the wedged pages. Of course I have no idea if all is well under the hood, which is why I thought it worth mention. But I'm fairly sure I also had the problems in non-saved-sessions too. –  Bill Dubuque May 8 '12 at 23:31
@DavideCervone, big thanks, i will try it out. –  no identity May 9 '12 at 13:21

No, I have no major problems browsing MSE with Chrome recently.

Please upvote (don't downvote!) this answer if you have made significant use of Chrome to browse the MSE main site in the past couple of months without many freezes or crashes (Aw Snap!). Please add a comment mentioning your OS, Chrome version any other contextual information that may prove useful for debugging purposes.

-
Note: If you don't have any problems, please do comment with context: browser, OS, versions, etc. It would be very useful to determine a known working configuration. –  Bill Dubuque Apr 24 '12 at 6:34
I'll refrain from voting since I haven't really used the site as heavily lately, but I've had no trouble with MathJax (here or elsewhere) + Chrome 17-18-19 on OSX (10.6). –  Isaac Apr 24 '12 at 7:14
I haven't had any trouble with Chrome, mostly on Mac. But I'm not sure I have written any answers of 'non-trivial length'. –  Tara B Apr 24 '12 at 8:25
I didn't vote on this because I thought it was specifically directed to Chrome users. –  The Chaz 2.0 Apr 25 '12 at 1:27

I am writing this answer to bring to light another strange behavior I noticed today. This bug appears related to this one and so I don't think this warrants a new question post:

I was editing an answer. That window "Aw!Snap"ped and every other Stack exchange window, (two Math.SE windows and a chat stack exchange window) died. This is a good enough evidence in my opinion that Chrome is not the trouble maker.

But, well, I am not a Tech Savvy to comment on this issue, but this behaviour looks relevant to this bug and I have brought it here for the SE team.

Hope we can get this fixed at the earliest.

Edit: I had this happen to me again today! The time of this can be had from my comment below!

-
I had it the second time today. It is aweful!! –  user21436 May 1 '12 at 16:33
If Chrome is flawless, why do you think Firefox users are not seeing this bug? A conspiracy against Chrome? –  Jyrki Lahtonen May 2 '12 at 3:56
Dear @JyrkiLahtonen, I did not write that others are not facing this difficulty in my post. I don't use FF much and therefor am largely clueless. I am sorry if I miscommunicated something. Please feel free to edit out anything as such. Regards, –  user21436 May 2 '12 at 6:54
You have no reason to apologize. It is just that when people praise Google, I will start grinding my axe. On a good day I may just look the other way, but on a bad day ... –  Jyrki Lahtonen May 2 '12 at 7:00