APNG New and Notable

I have been meaning to post this for a while now, so its kinda old news. The APNG format for animated PNG images is currently available in Firefox 3 alpha releases. I saw that the latest Opera 9.5 alpha releases also support APNG (look under Other Changes). I am glad to see support for the new format getting some traction.

I also came across an neat variation on Justin Dolske’s APNG image editor extension. Holger Will created an editor that uses SVG (& SMIL) to create APNG images. Updated information here. SVG paired with SMIL-based animations can produce some very good animated PNGs.

Andrew Smith, the guy who worked on APNG in Firefox, also has some examples and a review of Holger’s work here.

WebRunner 0.7 – New and Improved

After much fooling around, WebRunner 0.7 is ready to release. This release has some small changes and some big changes.

Small Changes

  • The WebRunner command menu has been removed from the context menu and is now on a statusbar button menu. The commands had nothing to do with the web application content, so the context menu was a bad spot for the commands. See WebRunner:HostWindow
  • The statusbar is no longer allowed to be hidden. The status messages and progress meter, used during a page load, can still be hidden using the status config parameter. The statusbar is where the SSL lock information is displayed and we feel its important enough to always be displayed. See WebRunner:HostWindow

Big Changes

  • The simple INI webapp file used to configure the web application has been changed to a zipped archive. The configuration file is now inside the archive. Also, inside the archive are the window and desktop icons associated with the web application. In addition, an optional script file can be placed in the archive and used to tweak the WebRunner chrome window for the given web application. See WebRunner:Bundle, WebRunner:Config and WebRunner:Scripting
  • The WebRunner host window now has an optional Sidebar component which can be enabled using the configuration file and initialized via the webapp script. See WebRunner:Config and WebRunner:Scripting
  • WebRunner now installs web applications into its profile/webapps folder. Any web application launched via a webapp bundle (the zip archive) and has an ID (new configuration parameter) will be unpacked into the profile/webapps folder. Afterward, you no longer need the webapp bundle and you can launch the web application using the installed copy. See WebRunner:Bundle and WebRunner:Config.
  • WebRunner can create a shortcut to an installed web application on your desktop. The shortcut uses the web application icon. On Windows, a normal shortcut .lnk file is created . On Linux, a .desktop file is made using the web application icon. On OS X, an application bundle stub will be created (not implemented on OS X yet, sorry). We will get this working on OS X ASAP.

Installs for Windows, Linux and Mac can be found here. You can also find some example webapp bundles there too. The GMail bundle has an example webapp script that watches for new mail and displays a popup notification if any new mail arrives. I also added new webapp bundles for Facebook and Twitter.

Hello JS-CTYPES, Goodbye Binary Components

I have been working on a small project that ports Python’s ctypes functionality to Mozilla’s XPCOM system. For those unfamiliar with ctypes, its a Python module that allows developers to declare and call exported methods from binary/shared libraries. Developers can then wrap these binary calls in pure Python.

The JavaScript port, called js-ctypes, will give developers this same kind of functionality in Mozilla’s privileged JavaScript. The idea for the library came after helping many extension developers through the process of building binary (C++) XPCOM components. The story usually went something like this:

  1. Developer wants functionality not built into the Mozilla platform, but easily supported by the native OS.
  2. Developer wants to use a 3rd party library in an extension or xul app.
  3. Developer has methods in native code for performance reasons.

The usual answer to these problems is creating a binary (C++) component to act as a wrapper so the native features can be exposed to JavaScript via XPCOM. However, the process of building binary XPCOM components is significantly harder than JavaScript components. The macros and memory management rules of binary components are harder than JavaScript, but its really the compiler and linker flags, IDL, makefiles and SDK versions that make the process painful. The build process must be repeated for each platform too. For many cases, its just too much work.

The goal of js-ctypes is to allow developers to declare methods in binary libraries and then expose those methods as callable JavaScript functions. Developers can then create pure JavaScript library wrappers around binary libraries – without making binary XPCOM wrappers.

Here is a really simple example of using Window’s native MessageBox call from JavaScript:


const nsINativeType = Components.interfaces.nsINativeType;
 
function msgbox() {
  var library = Components.classes["@mozilla.org/js-ctypes;1"]
                          .createInstance(Components.interfaces.nsINativeLibrary);
  library.open("user32.dll"); // Load the shared Windows DLL

  var messageBox = library.declare(
      "MessageBoxW",          // name of the exported method
      nsINativeType.INT32,    // return type
      nsINativeType.INT32,    // parent hwnd (its a Window's thing)
      nsINativeType.WSTRING,  // Unicode message string
      nsINativeType.WSTRING,  // Unicode title string
      nsINativeType.INT32     // bitflag for buttons to show
  );

  var ret = messageBox(0, "This is the message", "Msg Title 1", 3);
  alert(ret);

  // You can reuse the method
  var ret = messageBox(0, "This is another message", "Msg Title 2", 3);
  alert(ret);
}

The js-ctypes code uses the same libffi library as the Python ctypes module. It is currently known to work on Windows and compiles on Linux, but I haven’t got around to testing it. We need to start the Mac implementation. We also need to add support for struct and more primitive types.

The code is in SVN here and we have a Bugzilla component too (see bugs, file bug).

Note: This functionality cannot be accessed from JavaScript used in web content. Only JavaScript that runs with chrome privileges (extensions and Firefox UI for example) can use js-ctypes.

Joel Spolsky and Weak Metaphors

Joel’s latest strategy letter is a long-winded diatribe on the current state of browser-based application development. There is some good stuff in there, but some of the metaphors are really stretched and the comparisons between desktop and web-based applications is a bit broken. Joel seems to think that web-based applications should support the same kind of features as desktop applications. This line of thought can only go so far.

For example, cut and paste between applications. I assume Joel wants to copy more than text from edit boxes and selected HTML from the page. No reason this couldn’t be done today (Live Clipboard anyone?) but doing so requires cooperation between the applications in question. The Web platform already supports it. And hey, the same kind of limits occur on desktop applications. Try pasting an Outlook contact into Quicken. On the Web right now, microformats and mashups provide functionality not easily possible in desktop applications.

Joel also brings up lack of UI consistency in web applications. Not so sure about this one. I believe a little bit of consistency goes a long way and many web applications share common UI elements and concepts. Let’s not forget just how consistent desktop applications can be. Microsoft Office seems somewhat consistent with its applications, except for the ribbon is missing from some. Sure, it may not be appropriate in all applications. I’m fine with that – just not overly consistent. And take a look at the UI’s of “web-style” desktop applications and media players and tools like Microsoft Expression (best if viewed with Silverlight). Again, just saying a little consistency goes a long way.

Finally, we get to the “NewSDK” concept. The super-do-it-all framework that all web applications use and Joel compares this to Microsoft Windows and the Windows SDK. Personally, I would be comparing the Web to Windows, not some framework that runs on the Web. Compare that “NewSDK” framework to MFC or WPF. In a followup post, Joel responds to readers who forwarded their version of the “NewSDK” by saying:

Indeed countless people have already emailed me to say that “NewSDK is here, it’s (choose one) Flex Builder, Google Web Toolkit, Java Web Start, Silverlight, JavaFX, Flash, ActionScript, MORFIK, OpenLaszlo, … (many omitted)” Ahem. These are not HERE until your TAXI DRIVER has heard of them, because I assure you he’s heard of Microsoft Windows.

Again, he’s comparing apples to oranges. Ask your TAXI DRVIER if he’s heard of the Internet. And again, I’d use MFC, WinForms, VCL as desktop examples of the “NewSDK” examples listed in the quote. Ask him if he’s heard of WPF.

Here’s another quote that rubbed me the wrong way:

If you’re a web app developer, and you don’t want to support the SDK everybody else is supporting, you’ll increasingly find that people won’t use your web app, because it doesn’t, you know, cut and paste and support address book synchronization and whatever weird new interop features we’ll want in 2010.

The ideas in this quote are exactly NOT what the Web is about. This is anti-Web. Forcing interop by mandating a framework is ridiculous in a place where open standards and formats are embraced. Web development can and is improving, but let’s not try to turn the Web into Windows. Of course, some people already are.

CMU Career Fair

This week I am joining Mike Schroepfer and Dan Portillio at the Carnegie Mellon career fair. Tuesday, September 18th 10:00 AM to 4:00 PM. We’ll be in booth 111.

Maybe some previous CMU/Mozilla interns will be there giving testimonials. See you there.

Software Freedom Day – Wrapup

Thanks to Douglas and the rest of the Carolina Open Source Initiative for putting on a great Software Freedom Day celebration at the University of North Carolina. There was a good bit of traffic through the event. We had plenty of people stop by our table.

I enjoyed Pam Sessoms’ presentation on using Pidgin (libpurple) and Jabber (XMPP) to allow multiple librarians to seamlessly answer questions from library patrons. There is also a feature that allows evening (after hours) questions to be routed between librarians at Duke and NCSU. I am a sucker for using off-the-shelf components to solve real problems.

Justin Scott had the SVG / Video demo running at our table. It turned out to be a big hit. I have a feeling my presentation on “Getting started with Mozilla” wasn’t as interesting.

Remnants of Hurricane Humberto made getting out of North Carolina harder than we thought.

SVG Bubble Menus

I was clickety-clicking my way around the Internet and came across the Connected Ventures website. The first thing that I noticed was the “bubble menu” system used on the site. Then I noticed it was written in Flash. Surely, I thought, SVG could be used to create bubble menus too.

I got a prototype working without much trouble. Then, I refined it a bit. Here are the files:
svg-bubblemenu-in-html.xml (demo)
bubblemenu.js

It’s a little slower than the Flash version, but that could be my inexperience with SVG. Feedback welcome.

Update: Jeff Schiller made some tweaks to the bubblemenu.js file (which I updated).

  • increased delta to be between -6 and +6
  • initialized groups once (don’t call getElementsByTagNameNS() with every tick
  • removed unnecessary setAttribute() on the groups’ x and y attributes (ed: yeah, didn’t remove some test code)
  • changed the setInterval() to 100ms (ed: I bumped up to 150ms to try to reduce CPU usage)
  • made sure the vertical speed was not zero
  • when a bubble goes off the screen, put it above the top (not
    randomly as you had it)

Thanks Jeff

ActiveState’s Open Komodo Project

Today ActiveState announced the Open Komodo Project, an initiative to create an open source platform for building developer environments. The project overview has lots of information on the details. Here is a good summary:

Open Komodo is not a product, but rather a code base upon which Integrated Development Environment (IDE) software packages can be developed. ActiveState’s Komodo Edit (free but not open source multi-platform, multi-language editor) and Komodo IDE (multi-platform, multi-language IDE for dynamic languages and Ajax technologies IDE) are existing, mature products that will use the Open Komodo platform.

In addition to the code base, the project will also start building a web development tool called SnapDragon:

The Open Komodo Project aims to create a full-featured web development tool for client-side web development integrated with Firefox©, Mozilla’s free, open source web browser, and based on the award-winning Komodo IDE. This new tool, codenamed Komodo Snapdragon, will be developed in collaboration with the open source community.

The project timeline gives information on how the project is expected to unfold. There seem to be many ways developers can participate in the project, including just lurking on the mailing list.

This project will provide some great open source code to the Mozilla platform for development tools. This is an area that many Mozilla developers feel is lacking and has been a much talked about issue for the new MozPad group as well. I look forward to a strong community forming around the project and using the code base to create many great developer tools.

Thanks ActiveState!

Developer Days – Prague?

There is a potential developer day forming in Prague (yes that Prague) for some time later this year. If you’re interested, check out the wiki entry. Add your name so we can get a feel for the interest level. Also, add some potential agenda items too.