Showing posts with label firefox. Show all posts
Showing posts with label firefox. Show all posts

Wednesday, December 27, 2006

Fast Firefox Fix Found

It's no secret that Firefox is a memory-leak hydra: every time the development team fixes one, two more spring up to take it's place. Build a large enough application and you're guaranteed to drop a few pointers here and there, and once you add in a Javascript engine, Chrome interfaces and a half-dozen or more extensions you might as well throw in the towel on your leak analyzer. This is the one area that Internet Explorer will always surpass Firefox. When you package most of your functionality as an integral part of the OS, your memory leaks are either found quickly or so deeply buried that you'd have to move Jimmy Hoffa to find them.

On the other hand, Microsoft Visual Studio 2005 leaks like a sieve, but it's the most helpful development environment I've ever seen. Perhaps memory leaks are found due to usefulness the way security flaws stem from popularity. That theory would conveniently explain the balance of bugs in Microsoft's OS code. But I digress.

There are some people (whose initials may be BMW) that will tell you that the best solution for this problem is to never install Firefox on a Microsoft OS. These are usually the same sort of people who still prefer vi to a text editor. Personally I'm not one to give up functionality for the sake of form, but what can a resource-constrained power-surfer do?

Well, the traditional method of freeing up resources lost to a leak is to restart the application. Back in the old days (like, three months ago) this was a major pain, involving bookmarking or finishing any open tabs, logging in to sites again and losing any form data that you might have entered on any open pages. Of course, there were extensions to fix any of those problems, but often they were a cause of the very problems you were trying to fix.

Thankfully, Firefox 2 fixed all that. I don't even want to know that you haven't updated yet, just go do it now. I'll wait. Anyway, Firefox 2 includes a crash recovery mode that can restore your entire session, usually without reloading the pages. Of course, this doesn't happen when you voluntarily close the browser, but you can see it in action when you install an extension. In fact, I suggest you check it out right now. Go install the Restarter extension from from the add-ons site. Once you've clicked the Install button (after the standard five-second penance), the Extension Manager will open to show the progress. Installing this tiny extension will probably take less time than the install delay. Once it's done, notice the Restart button? Click it. Go ahead, I'm patient.

That served two purposes. First, you have now seen the session restore function at work. Until now, the only way to trigger that as a user was after installing an extension. However, the tiny little extension that you just installed added an item to your File menu. At the bottom, just above Exit, there is now a Restart Firefox option. This will do exactly what the Restart button just did for you, so you can try this whenever the browser seems to have gotten bloated and slow.

This is far more convenient than a restart used to be, and it is guaranteed to free up any leaked memory, but it's still not always convenient. It's like rebooting the computer, almost guaranteed to fix the problem but sometimes like chasing a fly with a baseball bat. However, I found a potentially more useful tweak today in a post on Cybernet, which I found via Lifehacker's Best of April 2006. Here's what to do:
  1. Highlight the words config.trim_on_minimize and copy them to the clipboard.
  2. Open a new tab and type about:config in the address bar. This will display a page of Firefox's internal configuration values.
  3. Right-click anywhere on the page and select New -> Boolean from the context menu.
  4. Paste the copied text from above into the input box that appears and hit enter. Yes, you can type it if you'd prefer, I just found cut-and-paste more convenient.
  5. Select true as the value and click the OK button, then go to the File menu and click that new Restart Firefox option we just added.
So what did this accomplish? Well, now Firefox will unload most of itself from memory each time you minimize it. In my experiments, it went down to between 7M and 8M, from it's average of 40M to 50M (too many extensions loaded). Your results may (and probably will) vary, but from what I've been able to determine, at least some leaked memory is regained after you maximize the application. At the very least, you can free up a big chunk of system resources while you're doing something else without having to close the browser. This is a must for any serial tab abuser like myself, as well as anyone running on an ancient and/or overloaded system. I'm looking at you, Kare-Bear... just follow the instructions, you'll thank me later.

Tuesday, October 24, 2006

HOW-TO: Modify an extension to install under Firefox 2.0

[Ed. Note: Moving posts from my personal blog due to content considerations.]

The following steps have been tested on the del.icio.us Firefox extension. I read in this post by David Findlay that the extension seemed to work fine in Firefox 2.0 despite it's maxversion property. I attempted to follow the steps therein, but was too impatient and failed to wait for the second restart before giving up and uninstalling.

Due to my massive del.icio.us addiction, however, I had to invest a bit more effort. Creating XPI Installer Modules on the Mozilla Developers Center was extremely helpful, and a little guesswork led to the following procedure.

Step 1: Download the XPI file by right-clicking on the link (usually a big button that says something like "Install Now") and selecting "Save Link As..."
Step 2: XPI files are (conveniently) nothing more than specifically ordered ZIP files it turns out, so you can open them with just about any compression utility. I use IZArc out of habit and because it's free, but most any would do. You might even be able to do it from Windows without any special software if you want to badly enough. Whatever your preference is, right click on the XPI in explorer and use "Open With..." to view the contents of the file.
Step 3: In the root directory will be a file named install.rdf. If your compression utility allows you to edit files in-place within the XPI, open it up from there. Otherwise, extract the file and open it with any text editor. I'm a big fan of EditPad Lite because (again) it's free and knows how to deal with *nix carriage returns, but even notepad.exe will do fine for this.
Step 4: Find the line that says something like 1.5.0.* or and change the value to "2.0.*".
Step 5: If you had to extract the file to edit it, go back into the archive and delete install.rdf, then add your modified file. If you made your changes in-place, you can just save the file.
Step 6: If there is a folder labeled META-INF in the XPI, delete it. This contains the signature information for the extension, but it will no longer match since you made changes. However, it doesn't seem like much of a stretch to trust this particular unsigned XPI, since you just unsigned it.
Step 7: Do whatever you need to do to make sure changes to the XPI are saved, then close your compression utility.
Step 8: Right click on the XPI file, select "Open With...", then choose Firefox from the list. Click the Install button, Restart Firefox, and you're good to go.

Hope this works for everyone, it seems like a fairly easy procedure. Of course, you should keep in mind that some extensions are marked incompatible for a reason. Don't do this at all if you're not comfortable crashing Firefox completely, potentially losing all of your settings, probably suffering premature baldness and possibly going to hell.

LiveBlogging The Firefox 2.0 Release

[Ed. Note: Originally posted on my personal blog during a really slow period at work. Far more at home here.]

Word is that Firefox 2.0 is due to be released sometime this afternoon. Who the hell releases their software in the afternoon anyway? Are you going for that crucial after-school download market there or what? Anyway, I'm planning on playing with it as much as possible today, and I'm going to try posting results as I'm able throughout the day. Why? Hmm... nothing better to do?

9:45am
For those of us saddled with day jobs at which we can fake-work by testing new software, it appears that the Firefox team really ought to change how they build URLs if they want to keep their software to themselves through the morning. You can go download it from the ftp site if you're a little clever.

9:51am
My two favorite extensions, the plug-in for del.icio.us and the Tabrowser extension, are not compatible with the new version. Le sigh... I know a lot of Tabbed Browsing was included in the new version, I'll have to find my key functions in the options panel.

10:00am God I love the internets. It seems that David Findlay (whoever that is) has been kind enough to solve my problem for me. I haven't tested it yet, but this blog post gives details on how to get the del.icio.us extension working in Firefox 2.

10:27am It looks like you probably want to read David Findlay's post before you upgrade rather than after. I was unable to get it working post-install, and it looks like I may have to do some real work before I can try again. OTOH, if all it takes is a minor text edit to make it work, maybe the del.icio.us folks will get it working pretty quickly. I'd check their site before I went to too much trouble if I were you.

10:47am I miss my Tabbrowser extension. I have yet to find a way to get the search bar to open searches in a new tab.

10:56am You can configure Firefox 2 to automatically subscribe to feeds using Google Reader. Sweet. Check under Tools->Options->Feeds->Subscribe To Feed Using. Other pre-loaded options include Bloglines and My Yahoo, but I'm sure someone will figure out how to put everyone's personal favorites in there soon. Really, though, I'm pretty sure your personal favorite should be Google.

11:49am History->Recently Closed Tabs. Idiot protection for my occasional bouts of hyper-aggressive resource-releasing.

11:56am Firefox Build Engineer J. Paul Reed on why no one should do what I'm doing. Take it from me, kids, downloading pre-release software is neither safe nor a good idea. But it does beat hell out of real work.

1:13pm Just back from lunch, and David (do I know you, David?) has left a comment saying that the del.icio.us extension mod that I posted before worked for him, both at work and at home. It's possible that I was just impatient, as it apparently does not activate the first time you restart but does by the second restart. Whatever you do, it should be noted that clicking the uninstall button is not a good idea under any circumstances if you want to get it to work later. Trust me.

1:32pm Cool new feature: there's a Restart Firefox button after you install an extension. I used to have an extension installed that did this, but it stopped working due to some versioning problem with the Firefox 1.5.0.x Extension Manager. I may yet add it anyway, if the trickery I'm trying now works out.

1:37pm Been using the new version for hours now, and I just noticed the form spell-checker. Of course, I noticed it because it believes that I misspelled "versioning" above, but I'll give it a pass because it's a neat feature. Apparently I could, if it bugged me enough, right click on this (or any) text box and turn spell-checking off for that control. I wonder if there's a way to add words to the dictionary?

1:40pm Super-cool. The "Restart Firefox" button re-opens any tabs. Didn't check if it will re-open multiple windows as well, but I bet it does. Oh, and my XPI hack seems to have worked to re-install the del.icio.us extension. I'll write it up in a minute, once I've tested a bit more.

2:49pm The Restart Firefox extension I mentioned earlier installs just fine, despite the fact that the minversion and maxversion properties in the install.rdf file are both set to 1.4. It didn't work under 1.5.0.*, and I really don't understand why it would work now. Any help?

2:52 pm It works even better than before, too. Just like the "Restart Firefox" button in the extension manager, it re-opens tabs. Again I'm too lazy to test with multiple windows.

3:32 pm Just posted the instructions for modifying the del.icio.us XPI in a separate entry. Not sure, but it looks like they may have already taken care of this in their posted install. I'm leaving work now, but more later once I start breaking shit at home.

7:24pm Take a few hours off and the whole world changes. The good news is, the release is now official, so you can disregard any earlier whinings warnings you received about pre-release software and download it now. The other good news is that updates came out for del.icio.us, Tabbrowser Preferences and Greasemonkey to keep them compatible with 2.0. I doubt that any of these updates did much more than update the maxversion property as I described, at least they are now official.

7:49pm I guess it kind of looks like I was wasting my time earlier trying to update them myself, but that wasn't really the point. I did learn a lot about how extensions are put together, and I got a comment from someone I don't even know. I did have two extensions installed that have not yet been updated for 2.0. The openselectedlinks extension didn't update, but I just uninstalled since my primary use for it has been supplanted since I found DownThemAll! (which did update). Feedview is a really cool little extension that formats the display of an RSS feed, but I went ahead and uninstalled it so I could see the supposed improvements in FF2's RSS display.

7:59pm Firefox relaunched their Recommended Extensions Add-Ons page along with the new version, and TechCrunch compares the new 20 to the old 11 to find the winners and losers. I've been waiting for 2.0 to come out to publish my own recommended list, so expect to see that as soon as I can remember to start calling them Add-Ons instead of extensions.

9:37pm I just installed a nice little extension called TinyMenu which (with a little bit of work) let me entirely eliminate one of the standard toolbars from my life. I got the details from the LifeHacker Download of the Day article, you probably should too.