Weekend Project: Open Source Alternatives to Adobe Flash on Linux

957

 

Linux users have never been well-served by Flash. The official browser plugin offered by Adobe has tended to lag behind releases for other platforms. Flash is available only for 32-bit Intel-compatible processor architectures, and it has long been a source of browser slowdowns, freezes, and crashes. And to all that the fact that it is a proprietary, binary-only blob, and you can see why many Linux desktop users want to free themselves from it. You can, with a little bit of time and preparation, this weekend.

You may wonder why you need Flash support at all. If you are an adult without kids, you may generally encounter Flash only in its use as a cross-platform video delivery mechanism, and in many ways this is the easiest usage of Flash to dispense with. There are video extraction tools and extensions to pull video right out of Flash wrappers at the click of a button, allowing you to forget it ever existed. If you do have kids, however, you likely see Flash games and interactive content all the time (perhaps even too often for your liking…), and for you, simply ignoring Flash is not a real option.

Finally, if you spend the bulk of your online time at tech-heavy Web sites (as many Linux users do), you probably see modern HTML, CSS, and JavaScript. But the further you stray from the bleeding edge of technology, the more likely you are to find a site built with Flash interactivity and navigation, from the dark days before DHTML and DOM scripting. Or to put it another way, although your LUG and your favorite distro probably do not use Flash on their sites, your local farmer’s market or Wild West reenactor troupe, sadly, might.

Unfortunately, many of the same things that make the official Flash plugin crash-prone also make the plugin difficult to replace — namely that the Flash specification is incredibly complex, with numerous APIs that change between releases of the official Flash platform. It covers both raster and vector graphics, wraps several different audio and video formats, handles animation, interactivity, and several different generations of Adobe’s scripting language ActionScript. As a result, to get solid support for all of these varying types of content, you will need to work with several different open source components.

The overall plan is to completely remove the Adobe Flash plugin first, then to install two open source Flash implementations that handle different versions of Flash content such that they gracefully fail-over to each other as needed, and finally to configure Flash-less browsing for some specific sites that offer more modern content-delivery options.

Remove Adobe’s Flash plugin

All major Linux web browsers support the same plugin format, the Netscape Plugin Application Programming Interface (NPAPI). This includes Firefox, Mozilla Seamonkey, Opera, Konqueror, Epiphany, Google Chrome, and Chromium. A plugin like Adobe Flash is a shared binary object tucked away in some directory where the browser knows to look for it. Adobe Flash’s is named libflashplayer.so.

To uninstall it, first open up your browser’s plugin preferences. For brevity’s sake, we will use Firefox in the examples, but the process is the same for other browsers; only the location of the tools is likely to be different. On Firefox, you need the Tools -> Add-ons menu item, in the Plugins tab. Disable the Flash plugin, then close the browser. The tricky part comes next. Depending on how you installed the plugin initially, removing the libflashplayer.so file could require different steps.

If you installed it via your distribution’s package management system, you should start by uninstalling the package the same way. If you installed it through the downloadable installer program provided by Adobe, though, you will need to remove it by hand. It is usually installed in $HOME/.mozilla/plugins, and you can simply delete the file from the command line.

But the above steps do not always work. Open up the URI about:plugins in your browser, and scroll down through the list to see if “Shockwave Flash” is still listed anywhere. If it is, then Firefox may have found libflashplayer.so in some other location, such as the system-wide /usr/lib/mozilla/plugins/. By default, about:plugins only reports the file name of the plugin, not the full directory path. You can change this by opening the URI about:config and looking at the plugin.expose_full_path preference. Set it to “true” by double clicking on the Value column, then return to about:plugins and find the full path to libflashplayer.so. Delete without mercy.

Install Gnash in stand-alone mode

With Adobe Flash gone, it is time to install the open source alternates. It will ultimately require two: Gnash and Lightspark. The two projects cover different versions of the Flash specification; Gnash is the more mature project, and supports Flash content up to version 8. Version 9 of Flash debuted sporting a rewritten version of ActionScript based on an entirely different virtual machine model; Lightspark implements this newer framework.

Take a look at your distribution’s package management software for Gnash packages. If you are in luck, there will at least two — one that specifically provides the browser plugin, and one that provides the “stand-alone” player. Install the stand-alone version, including any support packages it recommends, but do not install the browser plugin.

If a package is not available, you can fetch the latest version of Gnash from the project’s Web site. The newest release as of today is version 0.8.8. Compiling it can be painful, but only in the sense that it has a long list of dependencies due to the wide variety of media content the Flash format encompasses. You can trim down the list of dependencies by specifying a subset of the configuration options (such as GTK+ only, rather than GTK+, Qt, and framebuffer GUIs). Consult the Gnash reference manual for a complete list of the configuration options.

Install Lightspark in plugin mode

Next, install the second Flash-replacement, Lightspark. Again, start by checking for a Lightspark package in your distribution’s package management system. In this case, however, pay close attention to the version number. For Lightspark-and-Gnash co-habitability, you will need at least version 0.4.2.

If your distribution provides only an older release, you will need to compile and install Lightspark yourself. Visit the project’s site and download the latest release — as of right now, this is version 0.4.4.1. Installation instructions are provided on the project’s documentation pages, which also include generally-up-to-date links to third-party binary packages that might be available for your distribution.

However you install it, check that your browser can actually find and recognize the Lightspark plugin. Open Tools -> Add-ons and check that it is installed and enabled, and visit about:plugins, and look again for Lightspark in the list. You can get troubleshooting help at the Lightspark Web site if something goes awry.

Finally, if you are running Firefox 3.6.4 or later, you can switch on Firefox’s “out-of-process plugin” mode, which runs each plugin in a separate process to prevent plugin crashes from crashing the browser. Visit about:config, then right-click and select New -> Boolean. Enter dom.ipc.plugins.enabled.liblightsparkplugin.so as the preference name, and set it to “true.”

Installing Lightspark as the plugin and Gnash as the standalone works because Lightspark has the ability to query Flash content for version information. If the content uses newer Flash features that Lightspark supports, it will render the content as normal. If the content is older, however, it will call the Gnash library (which was installed as part of the stand-alone package) to handle the rendering instead.

Avoid Flash whenever you have an option

The last step in replacing Flash is to configure non-Flash content delivery wherever it is supported. This is a site-specific process, so you can safely skip it if you do not plan to visit any of the supported sites regularly. It centers around the use of Flash as a video content wrapper; many high-volume video sharing services are offering non-Flash alternatives that use HTML’s <video> element to place content directly in the page, rather than embedding a Flash player. In many cases, Lightspark and Gnash will handle the Flash video just fine, but as long as you have a choice, it can’t hurt to request HTML5 video instead — in fact, in most cases it moves forward the cause of free and open video codecs.

Chrome, Opera, and the latest development builds of Firefox all support the new WebM codec released earlier this year by Google. At the moment, YouTube is the only major video-sharing site serving up WebM-encoded HTML5 content, although rumors persist that it is coming soon to others (such as Vimeo). You must opt-in to YouTube’s HTML5 delivery system by visiting http://www.youtube.com/html5.

Several other sites offer HTML5 video content in the free Theora format, including Dailymotion and Blip.tv. Dailymotion’s content is accessible by visiting a different start-page URL, http://openvideo.dailymotion.com/, and Blip.tv’s by visiting http://www.blip.tv/html5 and selecting the “On” preference. The Free Software Foundation maintains a list of Ogg-supporting sites at its PlayOgg campaign, sorted by national origin. Theora creators Xiph.orgalso maintain such a list, including a section specifically devoted to video sharing (as opposed to Ogg Vorbis audio) services.

There are other sites, such as the aforementioned Vimeo, that offer HTML5 video in the non-free and patent-encumbered H.264 format. Although it is not a truly free solution, setting up your browser to play H.264 video on these sites does help to liberate you from the Adobe Flash plugin.

Flashing out

Currently, these video-sharing services are the only places where Flash is optional, which is nice, but not comprehensive. Lightspark and Gnash cover a considerable amount of the total Flash specification, but always bear in mind that they are unofficial re-implementations. Even though both do regular testing, out in the wild wild Web, you might find content that does not work correctly.

The best thing you can do is file a bug report about it. You should try and discern whether it is Lightspark or Gnash rendering the Flash content, though, to file a report in the right place. This is easiest with the out-of-process-plugin option. Open top or another process viewer to see whether Gnash is fired up when you visit the site. The Lightspark site has instructions for getting a backtrace in the event of crash. In any event, note the expected behavior and what the plugin actually does, then file your bug. Afterwards, remember to set aside a few minutes to help the farmers and reenactors re-tool their sites with CSS and JavaScript.