How to callback plugin thread on Safari 5.1 on OSX?

本秂侑毒 提交于 2019-12-02 07:51:27

Yeah, we had the same problem with Safari 5.1 in FireBreath (which you should definitely look at if you're not familiar with it); NPN_PluginThreadAsyncCall no longer works. You haven't specified which platform you're on, so I'll show you what we use on both Mac and Windows.

On windows, we create a message HWND and we post a message to that HWND passing a void* in the event data as the LPARAM; the void* is converted back to a pointer to a data structure holding the params that pluginthreadasynccall would normally take, the call is made, and the data structure is freed. The message window class we use is here, and here is where the call is made. (Note that we use the same mechanism for cross-thread calls in IE)

On Mac, we basically just use the objective-c performSelectorOnMainThread; we wrapped it into a class to make it easier to use from c++. The scheduler class we use is here, and here is where the call is made. Note that you need to be really careful because there are lots of possible race conditions with these and occasionally you end up with re-entrant code. FireBreath has dozens of hours of work put into perfecting the cross-thread calls; it's a deceptively tricky problem.

Hopefully this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!