Archive for the 'Mozilla' Category

Finding the textarea selection

Saturday, May 6th, 2006

A desperate web developer emailed me asking how make a bookmarklet that does something with the selected text, where the selected text is usually in a textarea.

He had tried using window.getSelection.toString(), but that doesn't work, because window.getSelection() is implemented in terms of DOM Ranges and it doesn't make much sense to have a DOM Range inside a textarea.

Here are some of the methods I tried:

Am I missing a sane solution that works in current versions of Firefox?

Porn-related crashes

Tuesday, April 25th, 2006

About 20% of Firefox installations include a crash-reporting tool called Talkback. If Firefox crashes, Talkback gives the user a chance to send information about the crash to Mozilla, along with optional comments. This information is mostly used to determine which crashes are the most frequent and to help developers fix the crashes.

In the last 40 days, Talkback has collected information about 105 crashes where the user mentioned porn. Many of these comments are amusing, and some are baffling. Highlights:

  • jackin it to porn
  • looking at porn you know during work
  • I was doing a homework assignment for sex education he wanted to look at gay porn for free so we know what sex looks like if we hadn't already had it so PLEASE STOP! i am over 18!
  • Surfing porn. Why, oh why, must you drag me away from my porn? (Okay, it was "literary smut" from Nerve. But, well, COME ON!)
  • Accessing a recipe website when a pop-up porn ad appeared
  • Surfing porn. Dude, what the hell, I need my pr0n!
  • Not looking at porn.
  • I tried to figure out the different codecs that are necessary for watching video if you are running Gxine or Mplayer etc. in Rammemory of Puppy linux. Win32 got their own and it costs. So I use pornosites to check. The easiest way to find clips.
  • I watched a damn good porn for which I payed 20$ per minute...
  • Trying to enjoy the internet. And porn wasn't even involved.
  • i was on my space i wasn't looking at porn or anything i hope my space is not an illegal program

Firefox “causes” breakup

Tuesday, March 21st, 2006

From bug 330884:

This privacy flaw has caused my fiancé and I to break-up after having dated for 5 years.

The reporter's fiancé had secretly used Firefox on her computer to visit dating sites such as JDate, SwingLifeStyle, and Adult FriendFinder. While logging into those sites, he told Firefox to never remember passwords for those sites. He then uninstalled Firefox, probably because he was worried that she would find out which sites he had been visiting.

Later, she installed Firefox for herself, and happened to need to edit the list of sites to never save passwords for. She quickly realized that he had been visiting dating sites in secret, and was also able to determine that he was still an active member of some of the sites. As one might expect, this led to a breakup.

Should the Firefox uninstaller offer to delete profile data, like most game uninstallers do, or at least notify users that profile data was not deleted? Can it do so in a way that won't confuse users too much or cause accidental dataloss? What about platforms like Mac where most programs (including Firefox) do not have an installer or uninstaller?

Fixing rsync errors

Sunday, March 5th, 2006

Apple's recent security update to rsync broke my non-clobber Firefox builds. I would get errors like:

rsync -a ../../dist/bin/ ../../dist/DeerParkDebug.app/Contents/MacOS
rsync: delete_file: unlink "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/dist/DeerParkDebug.app/Contents/MacOS/mangle" failed: Invalid argument (22)
rsync: symlink "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/dist/DeerParkDebug.app/Contents/MacOS/mangle" -> "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/nss/mangle" failed: File exists (17)
rsync: delete_file: unlink "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/dist/DeerParkDebug.app/Contents/MacOS/shlibsign" failed: Invalid argument (22)
rsync: symlink "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/dist/DeerParkDebug.app/Contents/MacOS/shlibsign" -> "/Users/admin/trunk/mozilla/fx-debug-shared-gcc401/nss/shlibsign" failed: File exists (17)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-23/rsync/main.c(717)

Phil Ringnalda was having the same problem, and pointed out this Fink news item to me. Since I already had Fink installed, I worked around the problem by installing Fink's rsync:

fink selfupdate-cvs
fink update-all
fink install rsync

That required doing a sudo gcc_select 4.0, which in turn required blowing away my Firefox dist directory. (I had switched to GCC 3.3 when I first got the PowerBook because Firefox didn't build reliably under GCC 4 at the time.)

Update 2006-01-13: Apple released another security update todayish, which fixed the problem.

Firefox memory leak progress

Saturday, February 4th, 2006

Update 2007-11-06: see also my more recent post on this topic, Firefox memory usage and memory leak news, from September 2007.

One of the more common complaints about Firefox 1.5 was that it leaked a lot of memory. I don't know how often these leaks were severe enough to cause noticeable slowdowns or thrashing, but enough Firefox users seem to care about memory leaks that I thought I'd post something about what we've done and what we're doing.

Two memory leak bugs were fixed in Firefox 1.5.0.1, released earlier this week:

  • 316775 - Leak when selecting.
  • 317478 - Leaks due to global scope polluter being removed from not enough (?) prototype chains.

In addition, the following memory leaks have been fixed on the trunk since the branch point for Firefox 1.5:

  • 241518 - Calling addEventListener with a closure holding a content node leaks the document. (Many Greasemonkey scripts use addEventListener, and they each live within implied closures. Otherwise, this leak pattern isn't too common, mostly because Internet Explorer 6 leaks under the same circumstances.)
  • 321283 - Using Find causes documents to leak.
  • 315708 - Should release found link and current window object from nsTypeAheadFind.cpp.
  • 315951 - Unknown content type dialog leaks domwindow.
  • 319123 - Leak with contentsink-parser-dtd cycle involving document.write().
  • 323441 - Memory leak if a site sets location and then document.writes (e.g. when visiting www.economist.com).
  • 323377 - Lots of leaks in nsInternetSearchService.
  • 323532 - Leak when using history autocomplete.
  • 315427 - Bad nullcheck in nsXULPrototypeElement::ReleaseSubtree, causing the Options window to leak if the remembered panel is the cache panel.
  • 323534 - CreateTreeWalker can cause leaks due to cycles created by closures.

The trunk seems close to not leaking huge object graphs during my typical browsing sessions (YMMV). The only big leak I still see all the time is a leak at Gmail. The leak might be related to the "unused XMLHttpRequest" leak that David Baron is working on, or it might not -- when I asked whether Gmail is considering working around the "unused XMLHttpRequest" leak bug, a Gmail coder said he didn't think Gmail created any XMLHttpRequest objects it didn't use.

David Baron's leak-gauge has been allowing more people to test for large memory leaks with their own browsing habits, extensions, and favorite sites. At least 19 people filed 30 memory leak bug reports found using leak-gauge, accounting for more than half of the memory leak bug reports (and most of the memory leak bug reporters) since its introduction. The bug reports look pretty useful, and are definitely more useful than general complaints about high memory usage after using Firefox for a few hours.

If you're still suffering a lot from memory leaks in Firefox 1.5.0.1 and/or want to help find memory leak bugs, head over to The Burning Edge and try out a trunk build. If you prefer to stick with stable versions of Firefox, don't worry -- many of the fixes that are currently only on the trunk will be included in the next scheduled update (currently planned to be called Firefox 1.5.0.2 and released in March), most of them will be included in Firefox 2, and all of them will be included in Firefox 3.

Leaks in extensions

Recognizing that memory leaks aren't always due to bugs in Firefox itself, Steve England and others have tested popular Firefox extensions for memory leaks. They found that Session saver, NoScript, IE Tab, and the combination of FlashGot and Filterset.G Updater cause leaks.

Giorgio Maone, the author of NoScript and FlashGot, has already fixed the biggest leak in NoScript thanks to Steve's bug report. He is now working on threading issues in FlashGot that prevent debugging and might be responsible for the leaks. Authors of the other extensions haven't been as fast to fix their leaks.

I also fixed several minor memory leaks in my own extensions recently, some found through code inspection and some found using leak-gauge. Search Keys 0.7.2 and below kept parts of search result pages alive for the lifetime of the window due to an unintentionally global variable (a missing "var"). Thumbs 0.6.1 and below kept the DOMWindow for the page Thumbs was last used on alive until shutdown.

Other causes of high memory usage

Memory leaks aren't the only thing that can cause Firefox to (appear to) use a lot of memory. See MozillaZine Fourms: Memory usage FQA and MozillaZine KB: Reducing memory usage.

Bugs involving multiple extensions

Tuesday, January 31st, 2006

I thought bug 324586: browser.xul leaks (with Flashgot & Adblock Filterset.G Updater installed) was notable for involving multiple extensions. Then I saw bug 325279: Firefox 1.6a1 crash on exit, which requires a combination of four extensions.

I wonder whether these are bugs in the extensions, bugs in Firefox that are tickled by extensions, or problems where the extensions interfere with each other directly (such as two extensions having global variables in browser.xul overlays with the same name).

Pictionary for geeks

Sunday, January 29th, 2006

Majken got me hooked on an online game called iSketch. It's similar to Pictionary: a word or phrase is chosen randomly, and one player tries to draw it while the other players try to guess what it is. We play with the "computer terms" list, which includes phrases like "dynamic link library", "personal computer", "arithmetic and logic unit", "hexadecimal", "Mozilla", and "intranet".

I'm playing right now with a few friends from the Mozilla community. Come join us in the user-created room called "Foxymonkies"! IM me or email me your AIM screenname if you want me to IM you next time we play.

iSketch requires Shockwave. I've played on Windows and Mac, mouse and touchpad.

Little-known fact

Sunday, January 29th, 2006

Chuck Norris can dereference a NULL nsCOMPtr.