views:

853

answers:

3

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.

+5  A: 

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 (http://firebreath.googlecode.com) 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!

Taxilian
Additionally, if it doesn't ever enter the plugin code and you're on windows, profiling chrome with *depends.exe* can give valuable hints.
Georg Fritzsche
Using the -plugin-startup-dialog allowed me to debug the initialization sequence and find the problem. Thank you!
eburger
Great! Now mark the question as answered please =]
Taxilian
+1  A: 

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.

eburger
A: 

Thanks very much for the tip! Firebreath is just what I am looking for. I am going to try it, and may post feedback later here.

Lloyd

related questions