Search code examples
npapiweb-worker

NPAPI plugin with Web Worker Thread


I am aware of accessing NPAPI plugin from Javascript and I was able to implement the communication between the two.

I wanted to know if it is possible to access the APIs exposed by the NPAPI plugin from the Web Worked Thread?


Solution

  • Access to an NPAPI plugin from a web worker thread is exactly the same as accessing any other DOM element from a web sorker thread. From the mozilla documention:

    There's no access to non-thread safe components or the DOM and you have to pass specific data in and out of a thread through serialized objects.
    

    NPAPI is not aware of web workers, thus it is non-thread safe. In fact, all calls in an NPAPI plugin that talk to javascript have to be made on the main thread; all NPN_ functions (with a few specific exceptions) must only be called on the main thread. NPAPI is not thread-aware.

    Summary: No, you can't.