开发者

pluginthreadasynccall hangs the browser

开发者 https://www.devze.com 2023-04-10 04:56 出处:网络
I need to call a javascript function from my plugin. In order to do that I have spawned a th开发者_如何学Pythonread using npnfuncs->pluginthreadasynccall(savedinstance, wcfEventForwarder, NULL). Insid

I need to call a javascript function from my plugin. In order to do that I have spawned a th开发者_如何学Pythonread using npnfuncs->pluginthreadasynccall(savedinstance, wcfEventForwarder, NULL). Inside wcfEventForwarder thread function, I am waiting for messages (on a POSIX message Q) which are posted by another library. My intention is to receive these messages and then pass the data (received in these messages) to Javascript. The issue is, when I am spwaing the thread using pluginthreadasynccall(...) from Invoke, the browser is hanging and I am not able to interact with the browser any more. Can you please help me with a solution?

Regards, Souvik


You have completely misunderstood the purpose of NPN_PluginThreadAsyncCall; it is not to start a new thread, but to run something on the main thread. Your wcfEventForwarder function will be called on the main thread, so if you then block it's going to hang the whole plugin.

the purpose of this function call is to give you a way to trigger a call back on the main thread since other then NPN_PluginThreadAsyncCall, no NPN_ functions can be called on other threads. If you want to spawn another thread, you should do it yourself using something like boost::thread or the threading APIs directly (pick your flavor).

You should also note that some of the newer browsers have apparently stopped supporting NPN_PluginThreadAsyncCall; in particular, it doesn't seem to work in Safari 5.1 on windows or mac and I've had problems with it on multiple other browsers (firefox and chrome) in certain configurations on Mac.


Are you calling NPN_PluginThreadAsyncCall from another thread , or inside the "plug-in thread"?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号