Plugin-watcher

From Open Source@Seneca

Jump to: navigation, search

Contents

Project Name

Plugin-watcher


Project Description

Firefox sometimes gets a bad reputation for crashing or locking up when a plugin such as Adobe Flash or Windows Media Player causes a problem. This project aims to solve this issue by adding code to Firefox such that when a plugin misbehaves, a dialog is presented informing the user so that they can take corrective action (disabling the plugin) or file a bug report with the right party. As a minimum this code will identify that a plugin is to blame; later versions would also strive to inform the user of the plugin's name and provide options such as temporarily disabling the plugin.


Project Leader(s)


Project Contributor(s)

Contact Fima to discuss participation in this project.

  • armenzg tested leaky plugin with success but without crashing the browser


Project Details

Expectations for 1.0 release

The following is a preliminary list of my expectations for the 1.0 release of PW:

  • Work on the code in accordance with the feedback I receive on the posted bug.
  • Get the C++ code to work on Macs.
  • Get the JS portion out of the browser and into a proper extension.
  • Improve the heuristics of the front end extension.
  • Provide more information about the plugin that is causing the issue.
  • Provide a way to disable the plugin.
  • Add code to the front end JS that will collect and display statistical information about overall plugin runtime.
  • Do plugin benchmarking and publish the results.
  • Prepare a manual for others on how to create extensions that works with the low level C++ code me and Brandon wrote.


Expectations for 0.1 release

We have two main goals for the 0.1 release:

  • Modify NullPLugin into LeakyPlugin - a plugin that leaks memory.
  • Introduce code that would acknowledge LeakyPlugin's existence.


Project News

  • Thursday January 17, 2008 -- Filed a bug with the Plugin Watcher 0.31 patch and a request for feedback Bug 412770.
  • Saturday November 3, 2007 -- Bug 194986 - Might be important especially if we run into problems testing out code when using adobe plugins.
  • Friday October 19, 2007 -- Our LeakyPlugin is complete and is based on simplePlugin (found at mozilla\modules\plugin\tools\sdk\samples\simple) instead of NullPlugin (being as NullPlugin only works under Linux). A patch and instructions on how to install and operate this plugin are provided below.
  • Thursday September 20, 2007 -- Bug 392351 seems like it might be a good one to watch, especially if plugin memory usage is made available.
  • Tuesday September 18, 2007 -- Project selection has been made but no specific news is yet available... stay tuned!


Project Accomplishments

0.1 Release - Our first release is up and running. To install it you must follow these instructions:

  • First download the patch for the source here (right click on the link and "Save target/link as..." to your mozilla directory). Once downloaded apply it in the /mozilla directory in your tree by issuing the following command:
patch -p0 < leakyPlugin.patch 

-- This will patch a number of cpp files in your tree.

(If you are only interested in getting the leakyPlugin portion of the release download this patch instead and apply it by issuing the above command.)


  • Now download this patch and place it inside your "/mozilla/?objDir?/modules/plugin/tools/sdk/samples/simple" directory. Issue the following command from that same directory in the console to patch your make file:
patch Makefile make.patch 
  • Now issue a "make" command in that same directory to compile the plugin source files into a dll/so file. This will create "npsimple.dll" or "libnpsimple.so" (on Linux) as well as a sub directory named "_xpidlgen".
  • Check to see if your "/mozilla/?objDir?/dist/bin/plugins" now contains the following three files:
  1. npsimple.dll or libnpsimple.so (on Linux)
  2. npsimple.xpt
  3. nsISimplePlugin.xpt
  • If it does not, in the console window return to your "/mozilla/?objDir?/modules/plugin/tools/sdk/samples/simple" directory and from there issue the following command:

if you are on Windows

cp npsimple.dll _xpidlgen/npsimple.xpt _xpidlgen/nsISimplePlugin.xpt ../../../../../../dist/bin/plugins/

or if you are on Linux

cp libnpsimple.so _xpidlgen/npsimple.xpt _xpidlgen/nsISimplePlugin.xpt ../../../../../../dist/bin/plugins/

-- This will copy the neccesery files to Firefox's plugin directory.

  • Now open the interface page in Minefield - note that the console notifies you that leakyPlugin has been loaded. Once the interface page has loaded you can start leaking memory.
  • How do you know that its working? Open the Task Manager (Ctrl + Alt + Del) if you are on Windows, or locate a similar program if you will be using Linux or MacOSX.

If you are on Windows you can view the Performance tab to get information about how much RAM is available and how much virtual memory Windows is currently using. You can also see the amount of memory currently being used by Firefox in the Processes tab. To get more information about each process go to the View menu on the top and click on "Select Columns ...", then in the pop up box select the information you want displayed. You can then arrange the list by name to watch the Firefox executable and observe the RAM being used up every time you press the Leak button on the web interface. Note that this can be achieved on Linux and MacOSX with a variety of tools, one of which - Top - should come pre-installed and can be invoked from issuing a 'top' command inside a console.


0.3 Release - We ran into some difficulties with the 0.2 release and are skipping directly to our 0.3 which is now finished. To install it you must follow the instructions below:

  • First you must download the patch file here (right click on the link and "Save target/link as..." to your mozilla directory). Once downloaded apply it in the /mozilla directory in your tree by issuing the following command:
patch -p0 < pluginWatcher.patch 

-- This will patch a number of cpp and JS files in your tree (browser.js and nsPluginSafety.h).

  • Now issue a "make" command in the following directories to compile the cpp files and rejar browser.js:
    • ../mozilla/?objDir?/browser/base/
    • ../mozilla/?objDir?/modules/plugin/base/src/

You are ready to go, simply launch minefield and browse to a page containing some type of plugin.

  • How do you know that its working? The plugin watcher does two things, anytime a plugin has a run time of a millisecond or longer there will be a console output showing you the runtime. If the runtime has exceeded certain built in limits, a warning message will appear as a yellow bar below the chrome advising you of this situation. As of 0.3 these limits are hard coded and are not changeable via GUI. You may however change them yourself by looking at browser.js. The PluginWatcherObserver class is well commented and should be easy to change to fit your needs.


0.31 Release - The cross platform version of our initial 0.3 release

  • First you must download the patch file here (right click on the link and "Save target/link as..." to your mozilla directory). Once downloaded apply it in the /mozilla directory in your tree by issuing the following command:
patch -p0 < pluginWatcher.patch 

-- This will patch a number of cpp and JS files in your tree (browser.js and nsPluginSafety.h).

  • Now issue a "make" command in the following directories to compile the cpp files and rejar browser.js:
    • ../mozilla/?objDir?/browser/base/
    • ../mozilla/?objDir?/modules/plugin/base/src/

You are ready to go, simply launch minefield and browse to a page containing some type of plugin.

  • How do you know that its working? The plugin watcher does two things, anytime a plugin has a run time of a millisecond or longer there will be a console output showing you the runtime. If the runtime has exceeded certain built in limits, a warning message will appear as a yellow bar below the chrome advising you of this situation. As of 0.3 these limits are hard coded and are not changeable via GUI. You may however change them yourself by looking at browser.js. The PluginWatcherObserver class is well commented and should be easy to change to fit your needs.


0.4 Release - Bug Filed

For the 0.4 release of PW I filed a bug with the 0.31 patch and requested feedback. I'm hoping to get some comments and suggestion and hopefully start a dialogue and perhaps even make some new contacts within the community which would only benefit the project. The bug can be found here. I have also compiled a list of possible goals for the big 1.0 release but it seems likely this list will change once I get some feedback on the code in 0.31. The list is just above on this page under "Project Details".

0.5 Release - MAC Compatibility

For the 0.5 release I decided to try and make PW work on a MAC. I will be trying out my code on one of the new MACs at ORI sometimes this week and will update this section accordingly.

0.6 Release -

For the 0.6 release I took our the code we hacked into "browser.js" and put it into a proper extension. Its a pretty basic extension at the moment but this is my first real attempt at an extension and I will be working on adding some type of configuration for the user.

To try it out you will need Minefield 3.0b3pre - 3.0b4pre with this patch applied with "patch -p0 < PW06.patch" in your mozilla directory. Once the patch is applied browse to 'mozilla/?objdir?/modules/plugin/base/src' and issue a 'make' command in this directory. All thats left now is to install the extension. First download the ziped extension here and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. Once Minefield is started go to the Tools menu and select Add-ons from the menu, Plugin Watcher will be displayed as an installed extension.

0.7 Release -

For this release I have fixed some bugs and upgraded the extension which now allows for user input.

  • Fixed notification bar bug where the user notifications would collect one on top of the other. The notification will now only appear if no other PW notifications are present.
  • Added option to turn PW on and off in the context and Tools menu.
  • Added a preference panel to the extension where a user can control various settings of PW.
    • Users may turn PW on and off.
    • Users may change the monitoring settings of PW to notify them when a certain run time has occurred, a certain number of times, within a certain period of time.
    • Users may view the current run time directly in the preference panel.

To try it out you will need Minefield 3.0b3pre - 3.0b5pre with this patch applied with "patch -p0 < PW06.patch" in your mozilla directory. Once the patch is applied browse to 'mozilla/?objdir?/modules/plugin/base/src' and issue a 'make' command in this directory. All thats left now is to install the extension. First download the ziped extension here and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. Once Minefield is started go to the Tools menu and select Add-ons from the menu, Plugin Watcher will be displayed as an installed extension.

0.8 Release -

This release has two parts. The first is a change to the low level C++ code based on Robert's review suggestions. You can download the new patch right here. Once again you will need to save the patch to your mozilla directory and apply it by issuing "patch -p0 < pw0.8.patch". Once the patch is applied browse to 'mozilla/?objdir?/modules/plugin/base/src' and issue a 'make' command in this directory to compile the new source.

Now that you have the new patch its time to talk about whats new with the extension:

The PW extension has a new feature, it now allows you to record your plugin's run time to a file. It is still fairly simple and more functionality needs to be built on top to make this really useful, but so far I have been able to combine this ability, along with an open source live charting program called liveGraph to display a live graphical representation of the plugin's run time. You can get more information about this new feature on my blog. To install the new extension, first download this zip file and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. Once Minefield is started go to the Tools menu and select Add-ons from the menu, Plugin Watcher will be displayed as an installed extension. To try the new recording feature, right click inside Minefield, select the "Start recording plugin activity..." option from the context menu and browse to any page containing a plugin. When finished right click inside Minefield again to turn the recording off. A file will be created inside your extension directory by the name PWMetrics.csv; this file will contain a table with your plugin's run time over the recorded period.

0.9 Release -

The latest core patch that goes with this release is v0.82. You can download this patch right here. Once again you will need to save the patch to your mozilla directory and apply it by issuing "patch -p0 < pw0.82.patch". Once the patch is applied browse to 'mozilla/?objdir?/modules/plugin/base/src' and issue a 'make' command in this directory to compile the new source.

Whats new with the extension:

Well lots is new on the extension side. The notification method has changed, the code has been cleaned and substantially shortened. A few small bugs have also been fixed. To install the new extension, first download this zip file and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. You will notice the new plugin load meter and the on/off indicator at the bottom right corner of the browser. Now browse to a plugin containing page and PW will do the rest.

0.91 Release -

The latest core patch that goes with this release is v0.91. You can download this patch right here. Once again you will need to save the patch to your mozilla directory and apply it by issuing "patch -p0 < pw0.91.patch". Once the patch is applied browse to 'mozilla/?objdir?/modules/plugin/base/src' and issue a 'make' command in this directory to compile the new source.

The extension:

To install the new extension, first download this zip file and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. You will notice a plugin load meter and the on/off indicator at the bottom right corner of the browser. This version adds the ability to enable/disable the PW extension directly from the status bar icon and adds a new type of popup notification that shows above the plugin activity meter to let the user know if a plugin has been consistently running high for a long period of time.

1.0 Release -

PW Core:

You can download the latest patch here. However since the patch has been granted 1.9 approval, it will be available as part of the tree once checked in (which should be soon).

The extension:

To install PW extension v1.0, first download this zip file and extract it to any location on your hard drive. In the extracted extension folder you will find a file by the name: 'pluginwatcher@fima.kachinski'; open this file in a text editor and replace the path in it with the absolute path of your extension folder. Now copy this file to your Minefield profile 'extension' directory and start up Minefield. You will notice a plugin activity meter and the on/off indicator at the bottom right corner of the browser.

New since last version:

- Fixed multiple listener registration bug. - Changed all new Date() to Date.now().

Personal tools
special sections