{"id":2959,"date":"2014-08-15T13:02:56","date_gmt":"2014-08-15T02:02:56","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=2959"},"modified":"2014-08-15T13:02:56","modified_gmt":"2014-08-15T02:02:56","slug":"the-story-of-a-tricky-bug","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2014\/08\/15\/the-story-of-a-tricky-bug\/","title":{"rendered":"The story of a tricky bug"},"content":{"rendered":"<h3>The Bug Report<\/h3>\n<p>A few weeks ago I skimmed through <a href=\"http:\/\/www.reddit.com\/r\/firefox\/comments\/2b81pf\/ongoing_memorymanagement_issues_in_ff_282930\/\">\/r\/firefox<\/a> and saw a <a href=\"http:\/\/www.reddit.com\/r\/firefox\/comments\/2b81pf\/ongoing_memorymanagement_issues_in_ff_282930\/\">post<\/a> by a user named DeeDee_Z complaining about high memory usage in Firefox. Somebody helpfully suggested that DeeDee_Z look at about:memory, which revealed thousands of blank windows like this:<\/p>\n<pre><code>  \u2502    \u2502  \u251c\u2500\u2500\u2500\u25000.15 MB (00.01%) ++ top(about:blank, id=1001)\r\n  \u2502    \u2502  \u251c\u2500\u2500\u2500\u25000.15 MB (00.01%) ++ top(about:blank, id=1003)\r\n  \u2502    \u2502  \u251c\u2500\u2500\u2500\u25000.15 MB (00.01%) ++ top(about:blank, id=1005<\/code><\/pre>\n<p>I filed <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1041808\">bug 1041808<\/a> and asked DeeDee_Z to sign up to Bugzilla so s\/he could join the discussion. What followed was several weeks of back and forth, involving suggestions from no fewer than seven Mozilla employees. DeeDee_Z patiently tried numerous diagnostic steps, such as running in safe mode, pasting info from about:support, getting GC\/CC logs, and doing a malware scan. (Though s\/he did draw the line at running wireshark to detect if any unusual network activity was happening, which I think is fair enough!)<\/p>\n<p>But still there was no progress. Nobody else was able to reproduce the problem, and even DeeDee_Z had trouble making it happen reliably.<\/p>\n<p>And then on August 12, more than three weeks after the bug report was filed, Peter Van der Beken <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1041808#c59\">commented<\/a> that he had seen similar behaviour on his machine, and by adding some logging to Firefox&#8217;s guts he had a strong suspicion that it was related to having the &#8220;keep until&#8221; setting for cookies set to &#8220;ask me every time&#8221;. DeeDee_Z had the same setting, and quickly confirmed that changing it fixed the problem. Hooray!<\/p>\n<p>I don&#8217;t know how Peter found the bug report &#8212; maybe he went to file a new bug report about this problem and Bugzilla&#8217;s duplicate detection identified the existing bug report &#8212; but it&#8217;s great that he did. Two days later he landed a simple <a href=\"https:\/\/hg.mozilla.org\/integration\/mozilla-inbound\/rev\/acf50ee376c3\">patch<\/a> to fix the problem. In Peter&#8217;s words:<\/p>\n<blockquote>\n<p id=\"comment_text_71\" class=\"bz_comment_text\">The patch makes the dialog for allowing\/denying cookies actually show up when a cookie is set through the DOM API. Without the patch the dialog is created, but never shown and so it sticks around forever.<\/p>\n<\/blockquote>\n<p>This fix is on track to ship in Firefox 34, which is due to be released in late November.<\/p>\n<h3>Takeaway lessons<\/h3>\n<p>There are a number of takeaway lessons from this story.<\/p>\n<p>First, a determined bug reporter is enormously helpful. I often see vague complaints about Firefox on websites (or even in Bugzilla) with no responses to follow-up questions. In contrast, DeeDee_Z&#8217;s initial complaint was reasonably detailed. More importantly, s\/he did all the follow-up steps that people asked her\/him to do, both on Reddit and in Bugzilla. The about:memory data made it clear it was some kind of window leak, and although the follow-up diagnostic steps didn&#8217;t lead to the fix in this case, they did help rule out a number of possibilities. Also, DeeDee_Z was extremely quick to confirm that Peter&#8217;s suggestion about the cookie setting fixed the problem, which was very helpful.<\/p>\n<p>Second, many (most?) problems don&#8217;t affect everyone. This was quite a nasty problem, but the &#8220;ask me every time&#8221; setting is not commonly used because causes lots of dialogs to pop up, which few users have the patience to deal with. It&#8217;s very common that people have a problem with Firefox (or any other piece of software), incorrectly assume that it affects everyone else equally, and conclude with &#8220;I can&#8217;t believe anybody uses this thing&#8221;. I call this &#8220;<a href=\"https:\/\/blog.mozilla.org\/nnethercote\/2014\/01\/02\/yeinu-your-experience-is-not-universal\/\">your experience is not universal<\/a>&#8220;. This is particular true for web browsers, which unfortunately are enormously complicated and have many combinations of settings get little or no testing.<\/p>\n<p>Third, and relatedly, it&#8217;s difficult to fix problems that you can&#8217;t reproduce. It&#8217;s only because Peter could reproduce the problem that he was able to do the logging that led him to the solution.<\/p>\n<p>Fourth, it&#8217;s important to file bug reports in Bugzilla. Bugzilla is effectively the Mozilla project&#8217;s memory, and it&#8217;s monitored by many contributors. The visibility of a bug report in Bugzilla is vastly higher than a random complaint on some other website. If the bug report hadn&#8217;t been in Bugzilla, Peter wouldn&#8217;t have stumbled across it. So even if he had fixed it, DeeDee_Z wouldn&#8217;t have known and probably would have had been stuck with the problem until Firefox 34 came out. That&#8217;s assuming s\/he didn&#8217;t switch to a different browser in the meantime.<\/p>\n<p>Fifth, Mozilla does care about memory usage, particularly cases where memory usage balloons unreasonably. We&#8217;ve had a project called <a href=\"https:\/\/wiki.mozilla.org\/Performance\/MemShrink\">MemShrink<\/a> running for more than <a href=\"https:\/\/blog.mozilla.org\/nnethercote\/2014\/06\/16\/memshrinks-3rd-birthday\/\">three years<\/a> now. We&#8217;ve fixed hundreds of problems, big and small, and continue to do so. Please use about:memory to start the diagnosis, and add the &#8220;[MemShrink]&#8221; tag to any bug reports in Bugzilla that relate to memory usage, and we will triage them in our fortnightly MemShrink meetings.<\/p>\n<p>Finally, luck plays a part. I don&#8217;t often look at \/r\/firefox, and I could have easily missed DeeDee_Z&#8217;s complaint. Also, it was lucky that Peter found the bug in Bugzilla. Many tricky bugs don&#8217;t get resolved this quickly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Bug Report A few weeks ago I skimmed through \/r\/firefox and saw a post by a user named DeeDee_Z complaining about high memory usage in Firefox. Somebody helpfully suggested that DeeDee_Z look at about:memory, which revealed thousands of blank windows like this: \u2502 \u2502 \u251c\u2500\u2500\u2500\u25000.15 MB (00.01%) ++ top(about:blank, id=1001) \u2502 \u2502 \u251c\u2500\u2500\u2500\u25000.15 MB [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,4544,4546],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2959"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=2959"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2959\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=2959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=2959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=2959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}