I am trying to modify the "cefsimple" example from the Chromium Embedded Framework (https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial), so that it uses a separate executable in order to launch its sub-processes on Windows.
However, this is not working as expected and it crashes every time on the call to CefInitialize in the main process, before any window pops up or any subprocess is launched. Call stack:
chrome_elf.dll!00007ffaa7fc1cfd()
chrome_elf.dll!00007ffaa7fba5fc()
chrome_elf.dll!00007ffaa7fb9c9b()
libcef.dll!00007ffa88dae13c()
libcef.dll!00007ffa882fc146()
> cefsimple.exe!CefInitialize(const CefMainArgs & args, const CefStructBase<CefSettingsTraits> & settings, CefRefPtr<CefApp> * application, void * windows_sandbox_info) Line 201 + 0xb4 bytes C++
Using: CEF version 3.2883.1539, 64-bit, C++, VS 2015, Windows 10.
My solution: I added another target (cefsimpleHelper.exe) in the CMakeLists, and used these instructions as a reference to modify the source code: https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-separate-sub-process-executable
cefsimple_win.cc: (entry point of the main executable)
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
CefEnableHighDPISupport();
CefMainArgs main_args(hInstance);
CefSettings settings;
settings.no_sandbox = true;
CefString(&settings.browser_subprocess_path).FromASCII("cefsimpleHelper.exe");
CefRefPtr<SimpleApp> app(new SimpleApp);
CefInitialize(main_args, settings, app.get(), NULL);
CefRunMessageLoop();
CefShutdown();
return 0;
}
process_helper_win.cc: (entry point for the sub-process launcher)
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
CefMainArgs main_args(hInstance);
CefRefPtr<SimpleApp> app(new SimpleApp);
return CefExecuteProcess(main_args, app.get(), nullptr);
}
Any ideas what might be the problem?
I think I found the solution, mostly by random trial and error :P
I've just added a call to CefExecuteProcess in the main executable, before CefInitialize:
Thanks for all the comments, I hope this will help others as well.