processexitnpapi

What's the right way to kill NPAPI plugin instance when close browser's page-tab but not quit the browser process?


On Windows, when close the referenced browser's tab, the plugin process will quit immediately. But on mac os x, when I close the browser's tab (not quit the browser's process), the plugin process still keep a long time, after that, it closed abnormal. Then my question is that how can I quit the NPAPI plugin process normally? Thanks for your answer and sorry for my poor English. BTW, my OS is mac os x 10.8, and I use Xcode 4.5.

Because my plugin must support chrome, I used 32-bit arch and I cannot use OC's ARC, and then I must manage memory manually. When I check my code, I doubt in the each time call NPP_GetValue I should use browser->retainObject, but only call releaseObject once when the instance is destroyed. I do not sure it anyway.


Solution

  • You don't. It's not up to you when the plugin process should end, it's up to the browser. Chrome, for instance, keeps plugin processes alive for a short time to avoid thrashing if someone, say, reloads a page with the only instance of the plugin, or navigates between two pages with the same plugin.

    Your bug isn't that the process is staying alive for a while, it's that it's crashing when it does exit. You should debug and fix your crash.