• XPI v2 – Making Extension Development Easier

    March 23rd, 2010 by jorge with 17 comments »

    Note: this is just me throwing some ideas around. It is not an official proposal or spec. Having said that, I would like everyone that has interest in extension development to read this post and tell me what they think.

    I’ve been an extension developer for a long time, and I like to think that developing extensions is actually quite easy. Maybe it has to do with my C++/Java background, where setting up a development environment is much more involved than using a text editor and zipping some files together.
    That doesn’t negate the fact that the Mozilla add-ons platform is old, and showing its age. There are a number of problems with it that make it hard to take the first steps into add-on development, and it’s amazing how little has been done to solve them over the past years. These are the top 3 in my mind:

    • Extensions can’t be installed or uninstalled without a browser restart.
      • That’s bug 256509. Can it be fixed? Probably, but it would take a major development effort.
    • The documentation about extension development is incomplete or outdated.
      • I’m working on this in the XUL School project, to be finished soon.
    • Getting started with a basic “hello world” extension is too much effort: install.rdf, chrome.manifest, chrome JAR, content, skin, locale, defaults, OMG!

    The last point is the one I want to tackle in this post. There’s a ridiculous amount of boilerplate, redundant coding to do even for the most basic of add-ons, specially if you’re making an extension that should be skinable and localizable. These are the specific problems I’ve identified:

    • There are two manifest files: install.rdf and chrome.manifest, in completely different formats.
    • They are both defined in relatively obscure formats. The install.rdf file is one of the very few places where RDF is still used in Firefox. Sticking to a dying format (at least in this context) is a very bad idea.
    • The default chrome structure (with content, locale, skin, etc.) is too bureaucratic and inflexible, and almost completely redundant. Most add-ons have exactly the same structure, and having to define it every single time is unnecessary.

    I think we can reimagine add-on packaging in way that simple tasks can be performed in the simplest of ways, and so that it can scale to be as fine-tuned as it is today. So here are my ideas.#1 Merge install.rdf and chrome.manifest into a single file. What format should be used? I think JSON is as good as any other, and Mozilla already includes a native and very fast JSON parser. This manifest file could also match the package.json manifests being used for Jetpacks. package.json is actually a pretty good name for the manifest file. Perhaps the same standard can be use for Jetpacks and other add-ons?

    #2 Default to the root extension directory for chrome URLs in order to minimize chrome.manifest declarations. This means that a hello world extension could have this structure:

    • helloworld.xpi2
      • package.json
      • overlay.xul
      • overlay.js
      • overlay.dtd

    And the manifest file would be something like:

    {
      id : “helloworld@xulforge.com”,
      name : “Hello World!”,  
      type: “2”
      compatibility :    
        { id : “{ec8030f7-c20a-464f-9b0e-13a3a9e97384}”,
          minVersion : “3.5”,
          maxVersion : “3.6.*”},     
      domain: “helloworldchrome”,
      overlays:      
        { source : “chrome://helloworldchrome/content/overlay.xul”,
          target : “chrome://browser/content/browser.xul”}
    }

    (Note: ‘compatibility’ and ‘overlays’ can be arrays when there’s more than one item. And the ‘domain’ value is a general declaration of the chrome domain.)

    In this new system, you would be able to have all of your chrome files in the root directory and have no need for chrome directives other than declaring your main overlay. Also, in your root directory you can have a locale or skin folder that the system would know how to handle without any changes to the manifest. If a file isn’t found in the locale or skin folder, then the system falls back to the root directory as a last resource. Of course it would still be possible to declare specific locations for content, locale and skin in the manifest, in order to allow the “old style” to be used.

    What about other special locations?

    • platform and components will continue to have their special meanings.
    • JSM files can be handled just the same as chrome files, except that they use resource:// instead of chrome://.
    • The default preferences file should also be moved to the root and have a predetermined name, like defaultPrefs.js.

    #3 Installing the package. When you install an XPI file, the file is unpacked in your profile directory. It is common (but not mandatory) practice for chrome files to be packed in a JAR file, which remains packed after installation. According to recent discussions about add-on performance, it’s more efficient to keep files packed together. Instead of requiring authors to use the internal JAR approach, I think it makes more sense to require authors *not* to use JARs, and then keep the packed XPI in the profile on installation. Files that need to be extracted, like the manifest (maybe) and binary components (according to this) can be extracted upon installation. This way it’s up to the platform and not the developer to look after performance.That’s it. Given that this new packaging system would be backwards-incompatible with the current one, it might make sense to change the file extension to something like XPI2, in order to make a clearer distinction between the 2. However it should suffice to look for the manifest file in order to identify the system in use.
    How hard is this to implement? I think #1 and #3 are fairly simple to implement. #2 is the one that may present a bigger challenge, since the chrome URL system is something that runs deep in the Mozilla code, and changing its file location rules could cause breakage or vulnerabilities in non-add-on code. It might also be possible to limit the scope of these changes to add-ons only, but again, that may require lots of work. I’d love to hear the opinions of those who work on this part of the platform.

    Some may wonder how does Jetpack fit into this whole idea. Well, Jetpack is a different platform, and it may very well replace traditional add-ons in the long term, but we’re still a long ways to go. We shouldn’t see Jetpack as some kind of competition, but as a lesson in what we can do better. If we improve add-on packaging to be closer to Jetpack packaging (I think this would be), then it’s a win for both, because it’ll make it less painful for developers to choose and switch between either platform.

    I’d love to hear what experienced developers (both add-on and platform) think about this. I think there’s a real gain for novice developers in this if we were to implement it. I intentionally left out some details for brevity, but I’ll be happy to discuss them in the comments. Thanks for reading.

  • MAOW Perú afterthoughts

    March 4th, 2010 by jorge with no comments »

    The first Latin American MAOW (Mozilla Add-ons Workshop) was held last Saturday in Lima, Perú. The event was organized by Percy Cabello from the Mozilla Perú community, also the maintainer of the very awesome Mozilla Links blog.

    I did the first part of the workshop, explaining extension development.

    Me explaining stuff

    I learned from this experience that it’s not a good idea to cover all of the boilerplate parts of extension development in a presentation with such limited time. For future events I think it’s a better idea to have some sort of required reading before attending, so that it’s easier just to dive into the actual juicy parts and get stuff done. I still managed to cover several topics surrounding extension development, and the slides were full of references that people can follow to continue learning about the topic.

    The second part of the event was about Jetpack development, and was presented by newly appointed Jetpack Ambassador Hernán Rodríguez, from Agentina:

    Hernán showing shinny stuff

    Hernán did a fantastic job. I also should give Jetpack some credit because it is incredibly easy to get started in a few minutes. The attendees had a chance to play around and do more experimenting than on my presentation. We had some fun playing around with Hernán Twitter slidebar and messing around with CSS transformations.

    The event was a great success, and this was all thanks to the great work of the Mozilla Perú community. I was pleasantly surprised of how well organized they are, and the great deal of large-scale technology events that are held in Perú that could be good platforms for Mozilla to attract new community members.

    Much more details about this event can be read (in Spanish) in the Mozilla Perú blog and Hernán’s blog:

    Thanks again to Percy and Mozilla Perú community for organizing this event. I hope to see you again soon!

  • Extension update

    July 27th, 2009 by jorge with 2 comments »

    Recently I’ve been occupying myself with several Firefox extension projects:

    1. Most of all, I’ve been contributing to the AMO editor team to keep the add-on review queues down to a manageable size. There’s a great deal of new submissions and updates due to the release of Firefox version 3.5. There are hundreds of updates that are minimal to non existent compatibility changes, so I’ve been able to review close to 200 updates on this month alone. I enjoy my work with the editor team, specially because I’ve very fond of doing code review and being ruthlessly critical. It’s in my nature, what can I say… There are plans for removing the AMO sandbox, which I find intriguing, to say the least. I wonder how that will change the editor group and their work.
    2. The Extend Firefox 3.5 competition has been officially announced. With an October deadline, it includes several new interesting categories to compete in. Jose and I are already working on Fire.fm 1.3, which will be our entry for best extension update. There’s a great deal of new features we’ll be putting into it, which I think will greatly improve our user experience. We’re also working on a few ideas for new add-ons. I hope to be able to submit a couple of entries to increase our chances of winning.
    3. Finally, the Add-ons Contributions pilot was introduced to AMO. This enabled add-on authors to request donations for their project right on AMO, giving our donation links more exposure and possibly allowing a few authors to remove donation requests from their add-on UI, which is always a loss for user experience. We have activated contributions for Fire.fm, and so far the response has been pretty good. We’re very happy about it and hope people will continue helping us out.

    I still feel in ‘break mode’, and hope to start working in full gear soon. There’s so much I want to do, and I still need to get everything sorted out. More updates soon!

  • Introducing My Personas

    May 28th, 2009 by jorge with 1 comment »

    For my first “official” Xulforge project, I decided to take on a relatively simple task, so that I could get the site and blog started quickly. This way at least I have some content to show for while I work on larger projects ;) . This first project is My Personas.

    This project is a set of skins for the Personas extension. Personas is a new approach to developing themes for Firefox and other Mozilla apps. Creating a skin is pretty simple: all you need is a header image and a footer image. Creating a good one is a little harder; you’ll need to fill a very, very large image area, while at the same time keeping in mind that only a tiny fraction of the image will be visible in the majority of browsers. Patterns and other artificial designs are probably easier, but mine are just extracts from my large photo collection, so it’s trickier.

    I have a list of the skins I’ve created in the project page, with explanations on why I chose the pictures. So far my designs are doing pretty well, with a few hundred active daily users at this time. You can see the user counts in my designer page.

    My skins were all created using The Gimp, and the pictures were taken with 2 different models of the Canon PowerShot (I upgraded recently). Artistic feedback is greatly appreciated.

  • Regarding Fire.fm

    May 27th, 2009 by jorge with 2 comments »

    Fire.fm is a project that a friend and I began in order to compete in the Extend Firefox 3 competition, particularly to participate in the Best Music Add-on, which was being sponsored by Last.fm. I was a big fan of Last.fm at the time, given that it offered free online radio all around the world.  Sadly, that ended somewhat abruptly.

    Anyway, at the time we were pretty excited about it, and we spent a great deal of time and effort making Fire.fm a sure winner. And we won! We won the Best Music Add-on category, and I think we weren’t allowed to win in others, because I think we should have won the general competition as well ;) . Needless to say, we were super happy with this, and we have been actively maintaining the add-on in our spare time.

    Fire.fm is, in a nutshell, a Last.fm radio player. It used to be a very easy way to tune into Last.fm radio without having to be on top of the website all day long. Our users loved it, and shortly we were in the AMO Recommended List.

    Sadly, Last.fm cut off their free radio service to most of the world shortly afterward, so at least I lost a lot of the motivation I initially had to continue making it grow. Still, I don’t want to abandon a project that still has much to be fixed, so I’ll certainly won’t quit until all the annoying bugs are solved. Most users have a very smooth experience with Fire.fm, but there are a few unlucky ones that have some serious problems, like not being able to listen to stations at all… New features in Fire.fm are probably going to be very rare from version 1.2.3 and later.

    Xulforge was already in my mind when we began working on Fire.fm, so I always kinda saw it as a Xulforge project. Xulforge was put on hold until very recently, so it feels weird trying to associate the two. I’ll keep Fire.fm in my project list, though, because I it was one of my first independent projects, and also because it has been very successful and I’m very proud of it.

    Fire.fm is open source, BSD-licensed (more on that in another post). So, if you want to take a look into our code, you’re more than welcome. See the Fire.fm Sourceforge Project Page for more information.

    Fire.fm Logo

    Fire.fm Logo