Writing a plugin using NPAPI + D3D. It works on Firefox, but the browser blacks out. Why?

你说的曾经没有我的故事 提交于 2020-01-16 00:53:35

问题


I'm writing a plugin, using NPAPI and D3D. I just simply put a D3D sample from DXSDK and NPAPI together. I receive a HWND when the plugin starts up, and I passed it to D3D to draw.

It works though. the control(a 400 * 300 rectangle) on the test page DOES show what I expected.

But all other area in FireFox window is black, including the menu bar. All other contents on the test page cannot be seen.

I tried just InitDevice(D3D) with the HWND and do NO rendering at all. But still got the same problem.

Can anyone help me out here plz?


回答1:


I've seen this happen a few times before; there are two different situations where I encountered it. The first is when I had something weird with my D3D initialization which aparently conflicted with firefox -- but I'm still not sure what I changed to get it working.

The second, which I hope is what you are encountering, is when I was initializing D3D and attempting to draw on the main thread. My theory (unproven) is that Firefox is actually creating its own DX context of some sort and so creating another one on the same thread conflicts. When we moved the init and drawing code to another thread it all started working.

This is one reason that FireBreath has so much code to help make things threadsafe and allow cross-thread calls back to javascript -- every time I've tried to do drawing on the main thread with OGL or DX I've run into problems somewhere.

Hope that helps!



来源:https://stackoverflow.com/questions/5101927/writing-a-plugin-using-npapi-d3d-it-works-on-firefox-but-the-browser-blacks

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