0

I wrote plugin for FireFox which offer method for choosing file. This method calls Win API function GetOpenFileName. When dialog "Open File" is shown and I do not switch to other window then all works ok. If I clicks browser window then all is blocked and after some time I see message that plugin has crashed. This problem is only in FireFox and is absent in Chrome and Safari. I think it is connected with fact that GetOpenFileName has own message loop. Is there simple way to correct this behaviour?

e.g. function SHBrowseForFolder works fine in FireFox.

In FireFox sources I see class MessageLoop and methods SetNestableTasksAllowed() which probably can solve this problem (at least this conclusion can be done from explanation in header). But in xulrunner-sdk-13.0.1 there is no header with class MessageLoop although there is xul.lib with function GetIOMessageLoop. Probably it is possible to take headers from FireFox sources but I think it will not be easy to use them in my project in VS 2010

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
user1807338
  • 195
  • 1
  • 1
  • 9

1 Answers1

1

The main thing you need to understand here is that you must never block the main thread in an NPAPI plugin. The functions you're talking about are all blocking calls, so you must never use them on the main thread.

If you call them on a different thread your problem should go away; note that when you do this you'll probably want to have a callback function (javascript functions come in as a NPObject that you can call InvokeDefault on) and you can only call NPN_InvokeDefault on the main thread, so you'll have to device a way to do the callback on the main thread.

taxilian
  • 14,229
  • 4
  • 34
  • 73