CefPostTask TID_RENDERER doesn't invoke.

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.

CefPostTask TID_RENDERER doesn't invoke.

Postby zezba9000 » Sat May 06, 2017 3:35 pm

When I use the "cefsimple" app and run the code below, "MyFunc" never fires:

Code: Select all
//CefRunMessageLoop();
while (true)
 {
  CefDoMessageLoopWork();

  if (!CefCurrentlyOn(TID_RENDERER))
  {
    CefPostTask(TID_RENDERER, base::Bind(&MyFunc));
  }

  Sleep(1);
}


I need to access the CefV8Context.

Win10, x64
CEF x86
VS 2015
zezba9000
Newbie
 
Posts: 4
Joined: Sat May 06, 2017 3:29 pm

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby fddima » Sat May 06, 2017 5:18 pm

Read wiki JavaScriptIntegration first. TID_RENDERER is thread in renderer process, not main process.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby zezba9000 » Mon May 15, 2017 10:30 pm

fddima wrote:Read wiki JavaScriptIntegration first. TID_RENDERER is thread in renderer process, not main process.


"MyRenderProcessHandler::OnContextCreated" never fires in "SimpleApp" example.
I add the interface "CefRenderProcessHandler" and override "OnContextCreated". Does nothing.
zezba9000
Newbie
 
Posts: 4
Joined: Sat May 06, 2017 3:29 pm

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby Czarek » Mon May 15, 2017 11:28 pm

zezba9000 wrote:"MyRenderProcessHandler::OnContextCreated" never fires in "SimpleApp" example.
I add the interface "CefRenderProcessHandler" and override "OnContextCreated". Does nothing.

Make sure to pass handler to CefExecuteProcess and attach debugger to the subprocess.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby zezba9000 » Mon May 15, 2017 11:48 pm

Czarek wrote:
zezba9000 wrote:"MyRenderProcessHandler::OnContextCreated" never fires in "SimpleApp" example.
I add the interface "CefRenderProcessHandler" and override "OnContextCreated". Does nothing.

Make sure to pass handler to CefExecuteProcess and attach debugger to the subprocess.


Still doesn't do anything. Thats the first thing I tried.

Code: Select all
// Provide CEF with command-line arguments.
  CefMainArgs main_args(hInstance);

  // CEF applications have multiple sub-processes (render, plugin, GPU, etc)
  // that share the same executable. This function checks the command-line and,
  // if this is a sub-process, executes the appropriate logic.
  CefRefPtr<SimpleApp> app(new SimpleApp);
  int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
  if (exit_code >= 0) {
    // The sub-process has completed so return here.
    return exit_code;
  }

  // Specify CEF global settings here.
  CefSettings settings;

#if !defined(CEF_USE_SANDBOX)
  settings.no_sandbox = true;
#endif

  // SimpleApp implements application-level callbacks for the browser process.
  // It will create the first browser instance in OnContextInitialized() after
  // CEF has initialized.
 // CefRefPtr<SimpleApp> app(new SimpleApp);
 
  // Initialize CEF.
  CefInitialize(main_args, settings, app, sandbox_info);
 
  // Run the CEF message loop. This will block until CefQuitMessageLoop() is
  // called.
  //auto t = std::thread(Foo, app.get());
  CefRunMessageLoop();


Code: Select all
class SimpleApp : public CefApp,
                  public CefBrowserProcessHandler,
              public CefRenderProcessHandler
              {
 public:
  SimpleApp();
  CefRefPtr<CefBrowser> browser;
  CefRefPtr<SimpleHandler> handler;
 // CefRefPtr<CefBrowserProcessHandler> render;

  virtual void OnContextCreated(CefRefPtr<CefBrowser> browser2,
     CefRefPtr<CefFrame> frame,
     CefRefPtr<CefV8Context> context) override;

  virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE
  {
     return this;
  }
zezba9000
Newbie
 
Posts: 4
Joined: Sat May 06, 2017 3:29 pm

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby zezba9000 » Mon May 15, 2017 11:48 pm

Notice lines:
Code: Select all
CefRefPtr<SimpleApp> app(new SimpleApp);
  int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
zezba9000
Newbie
 
Posts: 4
Joined: Sat May 06, 2017 3:29 pm

Re: CefPostTask TID_RENDERER doesn't invoke.

Postby amaitland » Tue May 16, 2017 2:36 am

If you haven't already read https://www.chromium.org/developers/how ... on-windows in particular the section on manually attaching to the child process.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

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