CefInitialize() returns true even if initialization fails

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.

CefInitialize() returns true even if initialization fails

Postby radar » Wed Jan 31, 2018 11:52 am

I have the following case (CEF 3.3202.1693, macOS):

- Browser helper executable is not set to executable (mode 644).

- I call CefInitialize() which returns true.

- This results where my app thinks everything is ok, but it's actually not, because CEF can't launch the browser subprocess and GPU process.

IMO, CefInitialize() should return false if the helper can't be launched. Or maybe there's some other workaround?

Here's a bit of debug output:

swtchr/n: initialize cef
[0131/174754.491692:ERROR:browser_gpu_channel_host_factory.cc(108)] Failed to launch GPU process.
[0131/174754.494074:INFO:swtchr_browser.cpp(523)] OnContextInitialized
swtchr/n: chromium initialization successful
[0131/174754.610851:INFO:swtchr_browser.cpp(397)] BrowserCreate: browser=0x7f8b59d55b80
[0131/174754.709676:INFO:swtchr_browser.cpp(198)] OnTitleChange
[0131/174758.334079:INFO:swtchr_browser.cpp(403)] BrowserClose 1
[0131/174758.334128:INFO:swtchr_browser.cpp(256)] DoClose
[0131/174758.334569:INFO:swtchr_browser.cpp(265)] OnBeforeClose

I.e even CEF seems to think that everything is fine. It allows creation of browser instances, etc, basically the whole life cycle -- except that nothing works, because the render process was never launched.
radar
Techie
 
Posts: 12
Joined: Thu Nov 30, 2017 3:16 am

Re: CefInitialize() returns true even if initialization fail

Postby Czarek » Wed Jan 31, 2018 2:53 pm

CefInitialize will return true if initialization in the Browser process succeeds. There is CefRequestHandler::OnRenderProcessTerminated, but it will get called only when process terminates, not when process fails to start.

I guess LogMessageHandler could be useful here, you could intercept process launch errors, there is a proposal here:
https://bitbucket.org/chromiumembedded/ ... -functions

Having a specialized callback for processes launch failures would be even better.

Until that try using existing API to detect if process launch failed. See for example what a call to CefBrowser::GetIdentifier returns when browser launch fails and when it succeeds. Same for CefBrowser::SendProcessMessage - if it fails, probably process launch failed. See also if CefLifeSpanHandler::OnAfterCreated gets called when process launch fails.
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: CefInitialize() returns true even if initialization fail

Postby radar » Thu Feb 01, 2018 1:51 am

Okay, thanks for the insights! I'll look into these options.

Also, since we know from the client code, where the helper is located, it's name, I'll add some sanity checks if it's there and if it's executable. That should sort out a couple of failure cases already...
radar
Techie
 
Posts: 12
Joined: Thu Nov 30, 2017 3:16 am


Return to Support Forum

Who is online

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

cron