Category Archives: c

Services.jsm

I just landed the patch for bug 512784 on mozilla-central. It adds a new module to the toolkit whose sole purpose is to expose memoized getters for common XPCOM services on a simple “Services” JS object. The first pass involved adding getters for the prefs service, observer service, window mediator, permission manager, IO Service, prompt service, and search service. This patch also updates Firefox’s browser.js to make use of the module, which means that trunk-based extensions that run code in Firefox chrome windows can start making use of it if they’d like.

Here’s an example of one of the changes:

+// Services = object with smart getters for common XPCOM services
+Components.utils.import("resource://gre/modules/Services.jsm");
 function getTopWin()
 {
-  var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1']
-                                .getService(Components.interfaces.nsIWindowMediator);
-  return windowManager.getMostRecentWindow("navigator:browser");
+  return Services.wm.getMostRecentWindow("navigator:browser");
 }

I expect to add some other services to it as I look at expanding use of the module (Mossop has some suggestions in the bug). We might also add an equivalent in Firefox for browser-specific services, if that proves to be useful. The end goal is to remove a lot of the XPCOM boilerplate junk we see spread around our front-end JS code, and a side benefit is the reduction of unnecessary getService() calls for services that are already guaranteed to be otherwise instantiated and kept around for the app’s lifetime. This necessarily implies that JS scopes where the module was imported will now have permanent references to services after their first use, which is worth keeping in mind, both when making use of of the module and when adding additional getters to it.

reviews, crashing plugins, and tab matches

I’m going to give weekly blog status updates a shot. I suspect planet already gets inundated with them near the end of the week, so maybe I’ll try adjusting my schedule by a few days. Or maybe I’ll end up just posting them on wikimo instead. Either way I’ll try to keep them interesting!

I didn’t think I was going to end up doing this, so I didn’t take detailed notes of everything I’ve done this week. I’m going to try to get better at that.

Accomplished this week:

  • tried to keep the review queue cleanup rolling from last week, but I think I netted out even (or slightly negative). Current state: 33 pending requests.
  • reviewed dolske‘s plugin crashing UI patches (bug 539848, bug 538910)
  • helped test the 1.9.3 alpha 1 branding changes (bug 543564)
  • wrote some additional tests for bug 512784 (consolidated smart getters for common services). ready to land once it gets rs=Mossop
  • spent some time reviewing patch for bug 480350 (tab matches in awesomebar)
  • wasted a bit of time arguing with RSnake on his blog

Up next (roughly in priority order):

  • shorlander‘s going to be filing bugs for proposed theme/UX changes, will need to triage/prioritize those with dao
  • need to make progress on browser.js cleanup/simplification – I want to get a list of actionable items by mid-next-week and get patching
  • I have some mobile blog post ideas and notes that I really need to turn into posts
  • try not to give up too much ground on review queue clearing
  • want speak to Ryan about some changes required for bug 511017 (allow default search plugins to be updated, allowing them to get locale-specific search URLs to avoid redirects through google.com)
  • would like to resolve bug 479334 (improved en-US spellcheck dictionary, including better merge scripts to ease taking changes from upstream hunspell and chromium). just needs a final test run and a couple of tweaks before landing, I think.

Ideally I think my “upcoming” tasks would be as granular and clearly defined as my “completed” tasks, I guess, but they’ll probably be easier to split out into specific tasks once some of the planning/exploratory work is done.

Transition

For the last year and a half or so my Mozilla work has been primarily focused on the Fennec project (Firefox for mobile devices). It’s been a great experience for a number of reasons, not least because we basically set out to create an entirely new Gecko-based browser front-end from scratch. That forced us to re-evaluate design decisions made in Firefox, and let us try something new with far fewer compatibility constraints. We ended up with new ways of doing default bookmarks, a trimmed-down version of the awesomebar, a new way of displaying pages so that panning is faster, entirely different UIs for many of the important browser functions (bookmarks, download manager, add-ons, preferences, common dialogs, etc.), among others. Some of the work we did also benefited Firefox directly, and a lot of the work that didn’t still has the potential to benefit Firefox with a little bit of extra porting/re-factoring effort.

In addition to being a fun project to work on code-wise, it also gave me the opportunity to work in a team that’s been rapidly growing. Since I got involved, a bunch of new contributors have joined in with contributions to the front-end: bcombee, stechz, vingtetun, fabrice, froystig and mwu, to name a few. Combined with the rest of the mobile team and the Mozilla project in general, the project’s in pretty good shape to kick butt in 2010 and beyond.

With the mobile team in good shape, and with Fennec 1.0 in the RC stage, I’m taking advantage of the new year to transition out of my focus on mobile and return my primary focus to “desktop-edition” Firefox. While I’ve had a great time on-loan to the mobile team, I’ve also missed working closely with the Firefox team on pieces of the product that got me involved with Mozilla in the first place, and I feel that I have some responsibilities that I haven’t been able to keep up with as much as I should while focusing entirely on Mobile.

So in the immediate future, I’m looking forward to contributing more actively to the Firefox team’s Q1 goals, but I’m not disappearing from mobile, either. I expect to continue doing some reviews for changes to the mobile code I know well and will generally help out where I can. I’m also still quite interested in eliminating many of the things that cause us to treat the projects as separate entities (on a code-level as well as organizationally). I think that ideally, having to choose between focusing on either “Fennec or Firefox” should make less sense as the two projects evolve and as mobile gets more established, and I’d like to work towards making that happen.

To that end, I’ll be writing up some of the lessons we’ve learned in mobile in the coming weeks, and talking about how to integrate those into Firefox.

404 Error Pages

Curtis Bartley wrote an update for Planet Firefox, but his blog isn’t hooked up yet. My blog is hooked up already, but I haven’t written any updates.

So we’re going to combine forces to bring you the latest in status updates. (I will also shamelessly use this opportunity to bump my blog’s latest post into this year – welcome to 2009, readers!).

Here’s a teaser:

“We want Firefox to override […] the user […] bad news”

Check out Curtis’ update over on his blog to get the full scoop.

Summit 2008

I’m in Ottawa now, after having survived the escape from Whistler. The summit was great fun. It was awesome to see such an amazing group all together in one place. The best part was having a chance to chat with several people I’d only ever interacted with on IRC or in Bugzilla (Neil, Matthew, Simon, Kai, all of the frenchmozilla guys, _FrnchFrgg_, Shimono-san, and others that I know I’m forgetting now).

I’ve posted some pictures of the trip on flickr, but Deb has a great set of pictures of our journey home specifically. The trip back started on Friday morning, when a bunch of us headed out to the floatplane dock at Green Lake around 10am. After about an hour or so spent waiting at the dock, we were notified that our floatplane couldn’t land because of heavy fog, so we had to make alternate arrangements to fly out of Squamish, which is about a 50 minute drive south of Whistler. These delays meant that we’d all be missing our flights out of Vancouver, so we spent nearly an hour on the phone with Jane at Air Canada, who was really quite excellent, patiently managing to rebook us all on different flights at no cost to us.

We eventually made it to Squamish by bus, where we boarded a floatplane for a 10 minute ride to Vancouver. I was surprised at how pleasant the floatplane experience was. I was expecting the ride to be bumpy and the cabin to be cramped, but it was quite comfortable, and was a great experience overall (it might have helped that I was sitting in the front row). We landed at Vancouver Harbour Water Airport in downtown Vancouver, and had to hurry to catch a cab to the airport. We just barely made it – thankfully our plane was delayed getting in so boarding was pushed back a little bit.

I was glad to be able to land in Toronto in time to head back home and get a little bit of rest before my flight to Ottawa this morning. I’m in Ottawa visiting friends and family this weekend, before heading back to Toronto on Monday night to prepare for a Tuesday morning flight to Las Vegas for Blackhat 2008. After Blackhat, I’m going to be in Calgary for a week, visiting with family and attending my cousin’s wedding, and I’m considering taking a weekend trip to London near the end of August, so I think it’s going to be a busy travel month for me… but I couldn’t think of a better way to start it out than with an exciting adventure leaving Whistler! 🙂

Firefox 3 for theme developers

Firefox 3 is quickly nearing release, and shaver has prompted me to exercise my blog-posting muscles and post about changes relevant to Firefox theme developers. Alex Faaborg has already done a great job explaining the goals of the new default Firefox 3 themes (with screenshots!). I wanted to dive in a bit further into the details of the platform changes relevant to theme developers looking to update or create new themes for Firefox 3.

A large part of Firefox 3 theme work on Windows was making it possible to give Firefox a platform native look on both Vista and XP. In order to allow a given Firefox build to change it’s appearance based on the version of Windows it was running on, changes were made to our chrome registration code to allow selecting different theme packages at run-time based on operating system version. This functionality is also available to theme developers, and isn’t specific to Windows – more details can be found on MDC’s chrome registration page.

Windows theme developers might also want to make use of the new ::-moz-system-metric(windows-default-theme) pseudo-class, which allows different styling based on whether the user is currently using one of the default Windows themes (Luna/Royale/Zune/Aero, not including Classic). This feature was added to allow the Firefox 3 themes to use hard-coded colors not available in the system color set, without negatively affecting third party system themes that might specify different clashing colors. This pseudo-class therefore allows a fallback to potentially less-appealing, but more compatible, system colors for non-default themes.

Firefox 3’s layout engine, Gecko 1.9, has also received many fixes that are likely to be useful for theme developers:

  • David Baron‘s patch in bug 401291 made several improvements to dynamic selector matching, which means that matching of selectors that include pseudo-classes like :first-child, :only-child, and :last-child will now be updated correctly when the DOM changes. Similar fixes were made to the :empty pseudo-class and the “+” combinator, and support was added for the “~” combinator (see CSS3 for more details).
  • Support was added for Animated PNG, which allows animation with 8-bit transparency. The Firefox throbber is an APNG image, for example.
  • Thanks to Cairo, Gecko 1.9 supports rgba and hsla colors in CSS, which allows specifying an alpha channel in CSS colors, to allow translucency. The Firefox themes use this in several different places for better integration with platform native colors.
  • Another win from Cairo is that border radii drawn using -moz-border-radius are now anti-aliased, which improves their appearance (bug 16380).
  • On Mac, Gecko now supports transparent windows, thanks to work from Colin Barrett and HÃ¥kan Waara (bug 307204). This brings Mac up to par with Windows (Linux still doesn’t support partial transparency).
  • On Windows, new -moz-appearance values have been introduced that map to Vista toolbar appearances (-moz-win-browsertabbar-toolbox, -moz-win-communications-toolbox, -moz-win-media-toolbox). Also new is support for system color values for “communications text” and “media text” (-moz-win-communicationstext, -moz-win-mediatext).

Lastly, and perhaps most importantly, I wanted to encourage theme developers to check out Themes changes in Firefox 3 on MDC. It’s not a complete guide quite yet, but it already contains some great tips to help you update your theme for Firefox 3, and it’s a great place for theme developers to share information about common pitfalls.

Confessions of a bugmail addict

I’ve developed a little bit of a reputation, at least among irc.mozilla.org regulars, for being pretty familiar with the bugzilla.mozilla.org bug database. A little too familiar, perhaps.

I thought it would be interesting to do a little bit of analysis on the 1.2GB mbox file that holds all of the bugmail I’ve received since April 2004, and to shed some light on the methods to my madness. Here’s graph that shows the number of messages per day, since April 2004 (each point is one day, the vertical axis is number of bugmail messages receieved on that day):

Bugmail per day

This might be surprising to some people. It was a surprising to me, to be honest, when I received 1882 bugmail messages on January 29th. I’m not sure exactly what happened on that day, but most of the bugmail was probably generated by Gecko 1.9/Firefox 3 blocker and approval triage. I suspect it’s not completely out of proportion compared to some other heavy Bugzilla users, though. I would be interested in seeing bugmail graphs for beltzner or mconnor or bz or dbaron, say.

Beyond the raw numbers, which I will attempt to rationalize later, there are a few things you might have noticed in the graph. The most obvious is that my bugmail volume has been increasing steadily since I first started receiving bugmail in 2004 (as far as I can tell, my first Bugzilla CC was on bug 48037 on April 11, 2004) . You can see drops in volume during the year-end holidays in 2006 and 2007 – the drops are less visible in 2004 and 2005. Weekends are also visible as pairs of dots near the bottom of the range (not as easy to see in this horizontally compressed graph).

I also wanted to see how my bugmail frequency matched up to the Firefox release cycles. Here’s a chart with the messages grouped per month, with major Firefox releases shown on the graph:

Bugmail per month

You can sort of see a pattern – a buildup of bugmail volume up until the release, with a drop right after the release. Obviously my involvement in Firefox releases has increased as time’s gone by – I had very little direct involvement in Firefox 1.0’s release, but I did quite a bit of work writing and landing patches for Firefox 2, and the bugmail volume reflects that.

Frequently Asked Questions

  • Do you read all of your bugmail?
    • Yes, for some definition of “read”. A lot of the messages I receive are quick to skim – flag or dependency changes, comments I don’t need to reply to, bugs being resolved – it probably takes me only about a second or two to skim past these, and since Gmail groups messages for the same bug together, I can quickly flip through threads and see what’s changed without too much context switching. Messages that require a response or further action are usually queued up in tabs that I’ll go through later.
  • How do you CC yourself on so many bugs? Do you have a script that crawls Bugzilla and CCs you?
    • Yes, I have a script. I call it MassCC, and I run it on Bugzilla twice a day. It CCs me on bugs where the sum of any 3 digits multiplied by any fourth digit is a Mersenne prime. (This algorithm means I end up only being CCed on bugs whose number contains a “1”, but this hasn’t proven to be a problem so far.)
  • How do you keep track of so many bugs?
    • Most of my knowledge of currently-active and recently-fixed bugs comes from going through a “confirmed bugs filed in the past three days” query at least once every two days, moving bugs to the correct component, marking duplicates, CCing people who might be able to help fix the bug, and providing input if I know what the fix is. When I first started doing bug triage I would look at all bugs, but the number of UNCONFIRMED bugs quickly became overwhelming. A lot of other folks regularly do UNCONFIRMED bug triage, though, and I love them for it. I’ll also sometimes pay attention to the #bugs channel while when I’m on IRC, where firebot announces bug changes. If I see something interesting I’ll click over and CC myself. Having that channel’s scrollback easily available helps with quick bug lookups, when I know something happened in the past 2 or 3 days.
  • I filed a bug 3 minutes ago and you’re already CCed. Are you watching me?
    • No, I am not watching you. Reed is watching you, and I have a special arrangement with him.
  • I’ve noticed gavin.bugzilla at gmail dot com always gets mail, no matter what I do in Bugzilla. What’s up with that?
    • That’s an address that’s been set up as a “global watcher”. It gets mail for every change on bugzilla.mozilla.org. I set it up a while ago when the global watcher capability was added to b.m.o, but nowadays I very rarely actually use it. It’s mailbox is currently 37% full (2427 MB of 6480 MB), with 287088 unread threads. If it wasn’t for the “New bug filed” notifications having a different subject line than the mail for changes to the bug itself, the unread count would reflect the number of bugs that have been modified since the account was created.
  • Isn’t all this bugmail too much?
    • It’s starting to be a little too much, yes. Things should get better as Firefox 3 is wrapped up, but I’ll probably adjust my bug watching habits anyways, to try and reduce the amount of mail I need to sort through. I currently have 49 addresses in my Bugzilla “watch list”, most of them generic QA contacts that let me receive bugmail for an entire Bugzilla component. I can probably reduce my overall bugmail volume a fair bit without really diminishing my ability to “know what’s going on”. I want to be careful not to narrow my focus too much, though, since I do like being able to keep track of things happening in the Mozilla world that aren’t necessarily related to my job.

Hi

A few people have suggested that I get a blog, so I did. I don’t have any big plans for what I’ll be blogging about, but I suspect a significant number of posts will be about Mozilla. I might get into the habit of writing about stuff other than Mozilla; I guess we’ll see.