Chrome and firefox will not support NPAPI for a long time. What are my options?

Chrome and Firefox announced that they will soon be removing support for NPAPI plugins.

See http://techcrunch.com/2013/09/23/say-goodbye-to-npapi/

For Chrome, I have several options, for example, switching to Native Client (NaCl) if I want to execute C ++ code from JavaScript.

But what are my options in Firefox?

Basically, I have a Firefox add-in created using the Add-on SDK, and I want to call C ++ code from additional script content (JavaScript). I have used NPAPI before, but now I want to move on to something that will be supported for a longer period.

Thanks in advance.

+4
source share
1 answer

Installing an NPAPI plugin for "calling C ++ code" is actually not very good. NPAPI plugins will be available for all websites, and not just for your add-on ... Are you sure that the material will not break if random sites access it in a way that you did not expect?

Anyway, there are various mechanisms for running binary code in Firefox today:

  • js-ctypes is the least painful and recommended way. Basically, you would define a C API / ABI with which you can import and interact with Javascript.
  • binary components of XPCOM. Basically, the entire Firefox backend is written or glued together using the XPCOM binary components. They can also be implemented in add-ons, although this is a pretty steep learning curve for getting started, and the documentation is scattered in many places and largely “incomplete”. Another huge drawback is that you need to recompile and re-test the modules for each new version of Firefox (not the case with js-ctypes).

Using the Add-on SDK will make things even more complicated, but you should use it already since you have been using NPAPI plugins right now.

I would recommend first determining if you really need the binaries in your add-on or the JS implementation (with modern features like typed arrays and possibly even asm.js via emscripten) and HTML5 (canvas, audio / video). And if not, if only lightweight js-ctypes were executed.

In addition, NPAPI plugins in Firefox no longer go away. While they will be available, but the user will need to enable them (click to play). Perhaps add-ons could get around this, and now they will allow them as needed. Therefore, there is no need to rush things.

+5
source

All Articles