iosart.com | projects | articles | photos | about

Firefox extension update failure

Update: This issue (bug 252543) has been solved in Mozilla, so the workaround is no longer needed.

I have written a Firefox extension which uses an XPCOM component. When the extension is installed and the user will try to install a newer version of the extension, the installation fails.

The reason for the failure is that the old version of the extension is already loaded when the new version installation is attempted. The XPCOM component DLL is in use and it cannot be overwritten with the new version of the DLL.

So, what happens is that the old version of the extension remains installed and the Extension Manager says “the extension will be installed the next time you start Firefox” no matter how many time you restart the browser.

Making the users uninstall the old version of the extension before installing the new one solves the problem, but it is not a very user friendly way of solving this.

My solution:

  1. Detect the situation. To detect the situation, my extension queries the Extension Manager on every startup. If it detects that there is a version of the same extension (self) with a status “toBeInstalled”, it probably means that the user has installed a new version of the extension and the installation failed. Otherwise the status would have been “installed”.
    If this situation is detected, I move (rename) the component DLL MyComponent.dll to MyComponent.dll.uninstalled. This will succeed, because you can rename a DLL when it is in use, even though you cannot remove or overwrite it.
  2. I then notify the user that an additional restart of the browser is needed.
  3. When the browser is started for the next time, the installation will succeed because the file
    MyComponent.dll is no longer in use.

One little point that shouldn’t be overlooked – we have created a new file, MyComponent.dll.uninstalled, in the components directory. This file will not get deleted when the extension is uninstalled, because we never installed it. To solve this, I have packaged an empty MyComponent.dll.uninstalled file with the extension. Because this file has and “uninstalled” extension, it is ignored by everyone. When it is time to uninstall the extension the file is removed along with all the other extension files.

I can provide the complete source code (in Javascript) for this technique on request.

2 Responses to “Firefox extension update failure”

  1. Craig Says:

    sounds like this will work thanks

  2. Robert Grayson Says:

    Meticulously as I followed your instructions, this extension will still not work for me (Firefox 1.5 WinXP, AMD Athelon 2.2). I do hope you keep working on it!! :-)