CEF RenderProcessHandler's callback methods not being hit

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.

CEF RenderProcessHandler's callback methods not being hit

Postby michaelb » Mon Jun 14, 2021 8:52 am

Hi, I am trying to do the Javascript-C++ bindings in our application and have most of the code in order.
The problem seems to be it does not work because the render process handler's lifecycle callbacks (onContextCreated etc) don't seem to be called, so the v8 bindings do not happen. Thus the javascript test dialog I have shows "undefined" instead of the string I am setting it to be in onContextCreated.
I've read all the posts on here with similar issues and cannot seem to figure out the problem. I have all the little things everyone else missed then seemed to get their app to work - overridden GetRenderProcessHandler, calling CefExecuteProcess on the app class that extends CefRenderProcessHandler, etc. The render process lifecycle methods just seem to not be hit, and the browser is working, yet the javascript bindings do not happen. I have been stuck on this for a while and would appreciate some help.
The Render process does return "-1" when initializing via CefExecuteProcess, no idea why, or if it is relevant.

So I guess, how do I get the render process to run, and what is the proper location in code to do this? Why aren't any of the methods getting hit? (I tried the single process mode flag as well and it didn't help). How am I having a browser running without the RenderProcessHandler running? I feel like I'm just missing one simple flag or something... I have everything in place like all the examples and tutorials online. Thanks in advance.
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby amaitland » Mon Jun 14, 2021 2:43 pm

How are you attaching the debugger to the render process? Breakpoints won't be hit unless you've attached the debugger.

Make sure you've read the multi process issues section of https://www.chromium.org/developers/how ... on-windows
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby michaelb » Mon Jun 14, 2021 11:20 pm

I know the methods aren't being hit, none of the logic or print statements or logs in them ever get hit, and CefExecuteProcess for the render process is returning -1. It's not a question of debugging the render process, it's the lack of the render process running. I have std::cout statements in OnRenderThreadCreated, OnBrowserCreated, OnContextCreated, none of them ever get printed out, even though we have a working browser. I also did do some of the debugging tips (single process, attached processes) and none of it seemed to help, as it appears the render process/threads just aren't running. This is where I am currently stuck.
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby amaitland » Tue Jun 15, 2021 12:35 am

What OS are you running?

CefExecuteProcess for the render process is returning -1


When running in the browser process you should get a -1 as per
https://magpcss.org/ceforum/apidocs3/projects/(default)/(_globals).html#CefExecuteProcess(constCefMainArgs&,CefRefPtr%3CCefApp%3E,void*)

If you have a working browser then you pretty much have to have working sub processes. How are you confirming they aren't running?

std::cout statements in OnRenderThreadCreated, OnBrowserCreated, OnContextCreated, none of them ever get printed out, even though we have a working browser.


Renderer/network/gpu/crashpad/etc all spawn separate process, they don't have a console/terminal window(s), you don't get to see the output by default.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby michaelb » Tue Jun 15, 2021 12:54 am

Hi, thanks for the fast reply.
I am on Windows 10 pro 64. It is returning -1 for what should be the render process (not the browser process), on a class called

class RendererApp : public CefApp, public CefRenderProcessHandler

and I am passing in RendererApp from our "CefManager" class like this:

CefRefPtr<RendererApp> app = new RendererApp();
int exit_code = CefExecuteProcess(mainArgs, app.get(), nullptr);

Makes sense about the console, however our universal Logger didn't print the entry into the methods as well. Perhaps that is also not solidly reliable, though it does seem to do the trick for all our other handler lifecycle methods (CefDisplayHandler, JsDialogLoadHandler at least...). Would printing the output to a file perhaps do the trick? In any case, I suspect it might be a dead end usage of several hours, as our logger should be reliable...

The only other hunch I have, that I am hesitant to investigate, is that our RendererApp isn't successfully overriding the CefRenderProcessHandler class so the "overridden" methods aren't getting picked up. Not sure why though. Any input on this thought? Does this class also need to extend the "CefBrowserProcessHandler" class (shouldn't need to though based on the documentation and examples I've seen...)...
And I do have this method:
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE { return this; }
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby amaitland » Tue Jun 15, 2021 1:20 am

Add the following command line args:
Code: Select all
--renderer-startup-dialog --no-sandbox


When you see a message box pop up, go to visual studio and a attach the debugger as per the `Manually attaching to a child process` section of the document I initially linked.

Use the CEF built in logging functions, whatever logger you've setup is unlikely to work with the sandbox enabled.

The debugger won't hit any breakpoints until it's attached to the sub process.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby michaelb » Tue Jun 15, 2021 2:26 am

Okay, I tried that and got the following results:
Every minute or so another pop up happened with "Renderer starting with pid: xxxx". In Visual Studio I attached the processes, that didn't stop the popup from happening, sometimes two at a time, with this message. And none of the breakpoints in the renderer got hit (onbrowsercreated, oncoontextcreated, onrenderthreadstarted). Perhaps because they ran instantaneously before I had a few seconds to attach the process. Also, it seems weird that there was a new renderer process every few seconds, sometimes two a time?
What does this tell us? Is this CEF manually starting render processes expected behavior, or does that mean somewhere in our code there is a loop restarting renderer all the time (not that I know of, just once in CEF Manager that is returning -1)

Also can you please post a link to the CEF logger documentation?

Thanks
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby michaelb » Tue Jun 15, 2021 3:19 am

Is the problem that I'm not passing the
Code: Select all
--type=renderer
argument into the CefExecuteProcess function?

This is the code now I'm using to launch the renderer process ... how/where would I (if I should) insert this arument? Could this be the issue? Or is this most likely not the issue
Code: Select all
#ifndef _WIN64
        char** args = new char*[1];
        args[0] = pathStr;
        CefMainArgs mainArgs(1, args);
#else
        CefMainArgs mainArgs(GetModuleHandle(NULL));
#endif
        CefRefPtr<RendererApp> app = new RendererApp();

        int exit_code = CefExecuteProcess(mainArgs, app.get(), nullptr);
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby amaitland » Tue Jun 15, 2021 4:09 am

Does your applications main entry point look like the cefsimple example?

https://bitbucket.org/chromiumembedded/ ... c#lines-49

Check the log file for errors, a file called debug.log should be in your bin folder.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF RenderProcessHandler's callback methods not being hi

Postby michaelb » Tue Jun 15, 2021 4:37 am

I don't have sandbox_info, but my understanding from the documentation was that this was an optional parameter. Is it not? Other than that, yes it seems to be basically the same, getting main args from the module handle instance. Do I need to attach the
Code: Select all
--type=renderer
for render process? I do not see that in the cefsimple example however, or documentation on how to properly do this, if it needs to be done. If everything here is okay, then we can rule out the entry point from being the issue.
My main entry point looks like this:
Code: Select all
#ifndef _WIN64
        char** args = new char*[1];
        args[0] = pathStr;
        CefMainArgs mainArgs(1, args);
#else
        CefMainArgs mainArgs(GetModuleHandle(NULL));
#endif
        CefRefPtr<RendererApp> app = new RendererApp();

        int exit_code = CefExecuteProcess(mainArgs, app.get(), nullptr);



There is not a debug.log file in the Release folder from my Visual Studio project that I am running in Release (which I am assuming is the equivalent of bin here, where all my .exes run from). I might not be aware of the location for the cef bin, if there is a special one.
michaelb
Techie
 
Posts: 21
Joined: Thu May 20, 2021 7:38 am

Next

Return to Support Forum

Who is online

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