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

442 views Asked by At

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

There are 1 answers

2
taxilian On

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!