Tuesday, 25 September 2007

Stabilizing Firefox for beta quality plugins (Flash)

Using the recent Adobe Flash plugin in Firefox is a two edged sword. On one hand, it gives you the never ending joy of useless YouTube videos, but on the other hand it crashes your browser every 24h on average (only if you are also using Flashblocker which reduces flash content activation by 80%, namely all the annoying ads).

Presumably because of Flash, nspluginwrapper was invented to wrap up software of vendors that are incapable of producing 64-bit version of their product. nspluginwrapper works by providing a proxy to Firefox that acts as regular plugin, but actually spawns off a separate process that runs in 32-bit mode that links in the shared object of the plugin. We can use this construction to remove Flash from the intimate dlopen embracement of Firefox and move all negative side effects of beta quality software into a subprocess. The following trick works for all 32-bit browsers, whether the rest of your distro is amd64 based or native i386. If you are
using a 64-bit browser, it's likely that you know nspluginwrapper anyway, so this blog entry is about 32-bit to 32-bit.

Grab a copy nspluginwrapper (at least 0.9.91.5). Untar it. Compile it under an i386 environment. If you don't have this at your disposal, here is it precompiled from my local Gentoo installation: nspluginwrapper-0.9.91.5.tbz2. This is compiled for the amd64 arch layout of Gentoo. Under native i386, just create a link from lib32 to lib in /usr.

Now grab a copy of libflashplayer.so. Drop it into a directory that is not part of your default Firefox plugin path and that does not contain the substring 'netscape' in its absolute path. So,
/opt/netscape/plugins/libflashplayer.so is wrong twice, /usr/lib32/nsbrowser/plugins libflashplayer.so is wrong only with respect to the default plugin path, and /usr/lib32/nsbrowser/wrapped-plugins/libflashplayer.so is correct.

The reason why the path must not contain 'netscape' is that libflashplayer.so presumes its part of a netscape installation when it sees 'netscape' in its path and malfunctions for Flash movies as on YouTube and Google Video under nspluginwrapper and Opera.

Invoke /usr/lib32/nspluginwrapper/i386/linux/npconfig -i /usr/lib32/nsbrowser/wrapped-plugins/libflashplayer.so. As super user, this creates npwrapper.libflashplayer.so in /usr/lib32/nsbrowser/plugins. Invoking this as normal user drops this file into ~/.mozilla/plugins. You are now read to go with your new shielded Firefox. Check that it contains a Section 'Shockwave Flash' under about:plugins referring to the npwrapper.libflashplayer.so file. If it refers to libflashplayer.so directly, you have a copy of libflashplayer.so laying around in a plugin path.

Flash might still cause lock ups in this setting. I presume Flash is getting stuck in an endless loop keeping Firefox busy even through the proxy. However, when that happens just kill the nspluginwrapper subprocess called npviewer. After that Firefox should refresh and you can just hit reload on Flash sites (instead of killing firefox and reloading all websites). Good luck.

No comments: