开发者

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 in开发者_运维技巧itialization related, because it kills it even if I don't access the plugin in any way.


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜