A NPAPI plugin doesn't work in Google Chrome
Asked Answered
U

2

5

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.

Usually answered 26/12, 2009 at 2:21 Comment(0)
C
15

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!

Chamkis answered 26/12, 2009 at 6:26 Comment(3)
Additionally, if it doesn't ever enter the plugin code and you're on windows, profiling chrome with depends.exe can give valuable hints.Tetrapod
Using the -plugin-startup-dialog allowed me to debug the initialization sequence and find the problem. Thank you!Usually
Could you tell us more what the problem was, if it's chrome-specific?Hemispheroid
U
5

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.

Usually answered 26/12, 2009 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.