Rg. OnWebKitInitialized not being invoked.

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Rg. OnWebKitInitialized not being invoked.

Postby swtsvn » Wed Apr 22, 2015 5:02 pm

Hi everyone.
I am using CEF to bind JS with C++.I am running into the issue that OnWebKitInitialized is not being invoked at all. The native code binding is solely depending on this callback (correct me if I am wrong. But the only way the JS can call C++ is via this OnWebKitInitialized and Execute methods)

Here is the pseudo code for the initialization process.
Code: Select all
void OnInit(){
HINSTANCE instance = wxGetInstance();
   CefMainArgs main_args(instance);

   CefRefPtr<CefApp> app = new MainHandler();
   int exit_code = CefExecuteProcess(main_args, app, nullptr);
   if (exit_code >= 0) {
      // The sub-process has completed so return here.
      return false;
   }

   // Specify CEF global settings here.
   CefSettings settings;
   settings.no_sandbox = true;
   settings.multi_threaded_message_loop = true;


   settings.ignore_certificate_errors = true;

   // Initialize CEF.
   CefInitialize(main_args, settings, app, nullptr);
}


Then in MainHandle class :

Code: Select all
class MainHandle :  public CefApp, public CefBrowserProcessHandler, public CefRenderProcessHandler
{
  virtual OnContextCreated //full syntax
  virtual void OnContextInitialized() override;
  virtual void OnWebKitInitialized();
  void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info) ;

  ..other related code
}


Here OnContextInitialized and OnRenderProcessThreadCreated are being called, because the MainHandle is a subclass of browser process handler. But none of render process handler callbacks are being called.

This issue seems similar to viewtopic.php?f=6&t=719, but it does not state a solution.

Any one know how to make the OnWebKitInitialized get invoked? or if something might be wrong with the code above that might hinder the callback calling?
swtsvn
Techie
 
Posts: 21
Joined: Wed Apr 22, 2015 4:56 pm

Re: Rg. OnWebKitInitialized not being invoked.

Postby magreenblatt » Thu Apr 23, 2015 2:27 am

swtsvn wrote:I am running into the issue that OnWebKitInitialized is not being invoked at all

OnWebKitInitialized and other CefRenderProcessHandler methods are called in the renderer process. You need to implement CefApp::GetRenderProcessHandler() and pass the CefApp instance to CefExecuteProcess(). See viewtopic.php?f=6&t=10567 #19 for debugging tips.

swtsvn wrote:(correct me if I am wrong. But the only way the JS can call C++ is via this OnWebKitInitialized and Execute methods)

That is incorrect. See https://bitbucket.org/chromiumembedded/ ... gration.md.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Rg. OnWebKitInitialized not being invoked.

Postby PolesApart » Thu Apr 23, 2015 8:21 am

magreenblatt wrote:See viewtopic.php?f=6&t=10567 #19 for debugging tips.


#19 points to a broken link in chromium.org
PolesApart
Mentor
 
Posts: 73
Joined: Fri Dec 05, 2014 1:24 pm

Re: Rg. OnWebKitInitialized not being invoked.

Postby swtsvn » Thu Apr 23, 2015 9:43 am

Thanks Magreenblatt. GetRenderProcessHandler implementation fixed it. Now my JS is able to call C++ native code function.

But the flow is on render thread -> Execute in CefV8Handler subclass which passes the function to Browser using CefBrowser->SendProcessMessage(), and again handled in Browser Handler(subclass of CefClient, sent to browser in CefBrowserHost::CreateBrowser()) in its OnProcessMessageReceived class.

This seems like a lot of jumping around from render thread to browser (excluding callback from browser thread to render thread again).

I read through https://bitbucket.org/chromiumembedded/ ... gration.md but again, all the native code call is done from render thread (for e.g CefV8Value::CreateFunction() in OnContextCreated().

My native code implementation is CPU intensive and cannot be run from render thread. Can anyone kindly point me towards the direction, where the browser process could send the native function call directly to browser handler (subclass of CefClient, sent to browser in CefBrowserHost::CreateBrowser()) ?
swtsvn
Techie
 
Posts: 21
Joined: Wed Apr 22, 2015 4:56 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 55 guests