0

I encountered a problem with updating the status message on Firefox from a Plugin code.

As the documentation says calling NPN_Status works only when called from the main thread. My requirement is to update the status from any thread within the Firefox process.

Any help would be appreciated!

atVelu
  • 815
  • 1
  • 12
  • 24

2 Answers2

1

You can't update it from any thread because that would violate some of the threadsafety rules. You will have to proxy your update back to the main thread.

sdwilsh
  • 4,674
  • 1
  • 22
  • 20
  • could you provide me with any example code / further details on how this proxy thing could be achieved ? – atVelu Jun 25 '09 at 04:48
  • You might be able to use https://developer.mozilla.org/en/NPN_PluginThreadAsyncCall, but I'm not certain. – sdwilsh Jun 26 '09 at 20:07
0

Like sdwilsh said, you are to call the NPN_*-functions only from the main thread. NPN_PluginThreadAsyncCall was only introduced in Gecko 1.9 and isn't supported in all current browsers.

Workarounds depend on the platform:

  • on Windows subclass the window your plugin receives, post/send messages to it and invoke the call from the handling window process
  • on Mac with Cocoa you can use e.g. performSelectorOnMainThread
  • on Mac with Carbon you can use invoke the calls on the null event
  • ... etc.
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236