Results 1 to 9 of 9

This is a discussion on NPAPI plugin in Chrome within the Plugins Development section, part of the Chrome Plugins category: Hello I have developed an NPAPI plugin for Firefox/Safari that I am now trying to get to work in Chrome ...


  1. #1
    markh is offline Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Default NPAPI plugin in Chrome

    Hello

    I have developed an NPAPI plugin for Firefox/Safari that I am now trying to get to work in Chrome without much success.

    After some debugging I have found that in Chrome the plugin is getting stuck when I am creating an ActiveX control. The ActiveX control is loaded from the plugin DLL via the usual CoCreateInstance. However, this call never seems to return and Chrome locks up. The relevant call stack is given below. It appears that it is getting stuck in CDllHost::GetApartmentToken.

    Anyone any ideas why?

    Thanks
    Mark

    ______________________________________________________

    Call Stack:

    Code:
     
    ntdll.dll!_KiFastSystemCallRet@0() 
    user32.dll!_NtUserMessageCall@28() + 0xc bytes 
    user32.dll!_SendMessageW@16() + 0x49 bytes 
    ole32.dll!CDllHost::GetApartmentToken() + 0x409e2 bytes 
    ole32.dll!DoSTApartmentCreate() + 0x12 bytes 
    ole32.dll!CClassCache::GetActivatorFromDllHost() + 0x556e5 bytes 
    ole32.dll!CClassCache::GetOrCreateApartment() + 0x20 bytes 
    ole32.dll!FindOrCreateApartment() + 0x46 bytes 
    ole32.dll!CProcessActivator::GetApartmentActivator() + 0x89 bytes 
    ole32.dll!CProcessActivator::CCICallback() + 0x17 bytes 
    ole32.dll!CProcessActivator::AttemptActivation() + 0x2c bytes 
    ole32.dll!CProcessActivator::ActivateByContext() + 0x46 bytes 
    ole32.dll!CProcessActivator::CreateInstance() + 0x49 bytes 
    ole32.dll!ActivationPropertiesIn::DelegateCreateInstance() + 0x4b bytes 
    ole32.dll!CClientContextActivator::CreateInstance() + 0x8f bytes 
    ole32.dll!ActivationPropertiesIn::DelegateCreateInstance() + 0x4b bytes 
    ole32.dll!ICoCreateInstanceEx() + 0x10b4b bytes 
    ole32.dll!CComActivator::DoCreateInstance() + 0x28 bytes 
    ole32.dll!_CoCreateInstanceEx@24() + 0x1e bytes 
    ole32.dll!_CoCreateInstance@20() + 0x34 bytes 
    npagraph.dll!ATL::CreateNormalizedObject(const wchar_t * lpszTricsData=0x10b9a164, const _GUID & riid={...}, void * * ppvObj=0x0127f540, bool & bWasHTML=false, wchar_t * bstrLicKey=0x00000000) Line 135 + 0x16 bytes C++
    npagraph.dll!ATL::CAxHostWindow::CreateControlLicEx(const wchar_t * lpszTricsData=0x10b9a164, HWND__ * hWnd=0x00190eec, IStream * pStream=0x00000000, IUnknown * * ppUnk=0x0127f540, const _GUID & iidAdvise={...}, IUnknown * punkSink=0x00000000, wchar_t * bstrLic=0x00000000) Line 844 + 0x1a bytes C++
    npagraph.dll!ATL::CAxHostWindow::CreateControlEx(const wchar_t * lpszTricsData=0x10b9a164, HWND__ * hWnd=0x00190eec, IStream * pStream=0x00000000, IUnknown * * ppUnk=0x0127f540, const _GUID & iidAdvise={...}, IUnknown * punkSink=0x00000000) Line 732 C++
    npagraph.dll!ATL::CAxWindowT<ATL::CWindow>::CreateControlEx(const wchar_t * lpszName=0x10b9a164, IStream * pStream=0x00000000, IUnknown * * ppUnkContainer=0x00000000, IUnknown * * ppUnkControl=0x0127f5ec, const _GUID & iidSink={...}, IUnknown * punkSink=0x00000000) Line 2036 + 0x38 bytes C++
    npagraph.dll!agraphfirefoxplugin::CreateToolbars(HWND__ * parenthwnd=0x00190ff2) Line 650 + 0x27 bytes C++
    npagraph.dll!agraphfirefoxplugin::CreateControlWindow(OWL::TRect & pluginrect={...}) Line 571 C++
    npagraph.dll!agraphfirefoxplugin::init(_NPWindow * aWindow=0x0101b738) Line 384 C++
    npagraph.dll!NPP_SetWindow(_NPP * instance=0x00fb0060, _NPWindow * pNPWindow=0x0101b738) Line 112 + 0x10 bytes C++
    chrome.dll!NPAPI::PluginInstance::NPP_SetWindow(_NPWindow * window=0x0101b738) Line 233 + 0x9 bytes C++
    chrome.dll!WebPluginDelegateImpl::WindowedSetWindow() Line 794 C++
    chrome.dll!WebPluginDelegateImpl::UpdateGeometry(const gfx::Rect & window_rect={...}, const gfx::Rect & clip_rect={...}) Line 388 + 0x1c bytes C++

  2. #2
    markh is offline Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Default

    Anyone got any ideas??

    Thanks
    Mark

  3. #3
    mg2's Avatar
    mg2
    mg2 is offline Senior Member
    Join Date
    Jun 2009
    Location
    Karlsruhe, Germany, Europe
    Posts
    328

    Default

    I don't know if this could be of any help but this extension also uses npapi plugin -> http://www.chromeextensions.org/utilities/switch-proxy/ so maybe some reverse engineering or contacting developer
    BETTER GMAIL for Google Chrome

    Win7 RC1
    Google Chrome Dev latest version

  4. #4
    markh is offline Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Default

    OK thanks - I'll have a look.

    Basically though my plugin is working. It is just when I try to create an ActiveX control, using CoCreateInstance, from within the plugin DLL that Chrome locks up. If I take out the ActiveX control creation from the code, then the plugin runs successfully. Therefore I am deducing that there is something odd about creating an ActiveX/COM object within the Chrome plugin environment.

    Haven't a clue what though!

  5. #5
    sarjoor is offline Senior Member
    Join Date
    Sep 2009
    Posts
    147

    Default

    Hi markh, you mentioned you already developed the NPAPI plugin for Firefox and Safari. Is it based on this code that you now have problems with? Are you sure the Firefox and Safari versions also create an ActiveX object?

    So far, IE is the only browser that supports ActiveX. Are you positive that a plugin that uses an ActiveX object works for Firefox and Safari?

    As far as I know, requiring ActiveX will definitely fail for all of Firefox and Safari and Chrome.

  6. #6
    markh is offline Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Default

    The plugin works perfectly in Firefox and Safari and I am now trying to use exactly the same plugin in Chrome.

    The plugin itself is a standard NPAPI plugin DLL and not an ActiveX control. I realize that ActiveX controls themselves are not supported by Netscape type browsers. The ActiveX control is created from within the NPAPI DLL and just provides part of of the UI for the plugin.

    As I said, the ActiveX creation works fine in Firefox and Safari. It is just Chrome that seems to have a problem. If I remove the UI element in the plugin code, and thus don't create the ActiveX control, then the rest of the plugin functions successfully in Chrome.

    Any ideas?

  7. #7
    sulasno's Avatar
    sulasno is offline Super Moderator
    Join Date
    Sep 2008
    Location
    Bangkok
    Posts
    1,759

    Default

    ActiveX is not supported in Chrome

  8. #8
    donaddon is offline Junior Member
    Join Date
    Nov 2009
    Posts
    7

    Default

    Judging by the callstack, you likely have some confusion over OLE apartment model threading (confusion can happen easily in this arena :-)). First off, ensure the COM objects you are using have been designated for the correct threading model (here's an example where that was the problem: http://blogs.msdn.com/asiatech/archi...d-handler.aspx).


    Also, there is something suspicious in that it looks like NPP_SetWindow in this case is not being called for initialization but for a geometry update. Be aware that NPP_SetWindow is called for events like resize, not just initialization, so you may be re-initializing your control at an inappropriate time.

  9. #9
    markh is offline Junior Member
    Join Date
    Nov 2009
    Posts
    5

    Default

    Thanks for the help. It did indeed turn out to be a threading model issue. When I added the following line into the manifest file for the ActiveX control, it solved the problem:

    threadingModel="Apartment"

    The plugin now functions 100% in Chrome.

Similar Threads

  1. DownloadHelper Plugin for Chrome ?
    By Boomdoom in forum Plugins Troubleshooting
    Replies: 30
    Last Post: 11-14-2011, 09:37 AM
  2. Adapting NPAPI plugin for chrome
    By Hansen in forum Plugins Development
    Replies: 16
    Last Post: 09-23-2010, 12:21 AM
  3. Help with java plugin for Chrome
    By Chrome77 in forum Chrome Troubleshooting
    Replies: 1
    Last Post: 10-11-2009, 05:12 PM
  4. java plugin for chrome
    By swth in forum Chrome Troubleshooting
    Replies: 2
    Last Post: 04-17-2009, 07:29 PM
  5. Open in chrome ff plugin help
    By Qinhas in forum Chrome Talk
    Replies: 4
    Last Post: 10-03-2008, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •