Search code examples
google-chromenpapi

A NPAPI plugin doesn't work in Google Chrome


I wrote a small NPAPI plugin using an old Mozilla NPRuntime example as a base. My problem is that it works fine on Firefox and Safari (on Windows), but it fails to work with Google Chrome.

I can see the plugin in about:plugins just fine and I see Chrome launching a new process for running the plugin when I open my test page, the plugin process dies in ~10 seconds without any error dialog. During the 10 seconds the process is alive accessing the scriptable plugin object doesn't work (which works fine when using Firefox or Safari).

Any ideas what could cause Chrome killing the plugin process after 10 seconds? Must be something initialization related, because it kills it even if I don't access the plugin in any way.


Solution

  • It is difficult to say for certain, but you can use the --plugin-startup-dialog command line parameter to have Chrome pop up an alert when it loads a plugin, in the same process. You can then attach the debugger to that process, and hopefully catch the error.

    You could look at FireBreath for comparison to see if you can spot any major differences in the initialization code, since FireBreath works fine in Chrome. I'd recommend attaching a debugger, though, and stepping through the code until it crashes. Set breakpoints at each entrypoint, on NPP_New, NPP_Destroy, and NPP_SetWindow, and see what happens.

    Another option would be to try building Chromium from source (not ridiculously difficult, but time consuming) and then you could get a full stack trace to where it stops working.

    Good luck!