Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 474
eburger Avatar asked Dec 26 '09 02:12

eburger


2 Answers

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!

like image 81
taxilian Avatar answered Nov 11 '22 07:11

taxilian


Thanks to Taxilian's tip I was able to debug the initialization sequence and found out that the example plugin was returning an error when Chrome was calling the plugin's NP_Initialize(). The example plugin had a check to make sure that the NPNetscapeFuncs structure definition used in the compliation of the plugin was at least the same size as the one offered by the browser. It appears that Chrome uses version 19 of the structure which is naturally smaller than version 22 of the latest Mozilla XUL Runner SDK from which I was getting npapi.h and npruntime.h.

like image 26
eburger Avatar answered Nov 11 '22 06:11

eburger