问题描述:

I'm using cefclient in my application pretty much as is, except for the entry point (cefclient_win.cc).

I start it up and a browser window shows up but nothing gets loaded in it.

After a while the refresh button is enabled, but clicking it does nothing as well.

In the log file I get this:

[0714/170658:WARNING:ipc_channel_win.cc(276)] Unable to create pipe "\\.\pipe\chrome.5432.0.197852861" in client mode: The system cannot find the file specified. (0x2)

[0714/170713:WARNING:ipc_mojo_bootstrap.cc(214)] Detected error on Mojo bootstrap channel.

[0714/170713:WARNING:channel.cc(130)] WriteMessage() while shutting down

[0714/170714:WARNING:ipc_channel_win.cc(276)] Unable to create pipe "\\.\pipe\chrome.5432.1.123441216" in client mode: The system cannot find the file specified. (0x2)

[0714/170730:ERROR:process_win.cc(134)] Unable to terminate process: Access is denied. (0x5)

[0714/170730:WARNING:ipc_channel_win.cc(276)] Unable to create pipe "\\.\pipe\chrome.5432.2.118634471" in client mode: The system cannot find the file specified. (0x2)

[0714/170742:ERROR:process_win.cc(134)] Unable to terminate process: Access is denied. (0x5)

[0714/170742:WARNING:ipc_channel_win.cc(276)] Unable to create pipe "\\.\pipe\chrome.5432.3.396064" in client mode: The system cannot find the file specified. (0x2)

Here's how I start the cefclient:

void MyCefApp::start() {

this->browserHandler = new client::ClientAppBrowser();

this->browserThread = boost::thread(boost::bind(&MyCefApp::run, this));

}

void MyCefApp::run() {

CefMainArgs mainArgs(GetModuleHandle(nullptr));

void* sandboxInfo = nullptr;

#if defined(CEF_USE_SANDBOX)

CefScopedSandboxInfo scopedSandbox;

sandboxInfo = scopedSandbox.sandbox_info();

#endif

CefRefPtr<CefCommandLine> commandLine = CefCommandLine::CreateCommandLine();

commandLine->InitFromString(::GetCommandLineW());

scoped_ptr<client::MainContextImpl> context(new client::MainContextImpl(commandLine, true));

CefSettings settings;

CefString(&settings.resources_dir_path) = RESOURCES_DIR_PATH;

CefString(&settings.locales_dir_path) = LOCALES_DIR_PATH;

#if !defined(CEF_USE_SANDBOX)

settings.no_sandbox = true;

#endif

context->PopulateSettings(&settings);

scoped_ptr<client::MainMessageLoop> messageLoop;

if (settings.multi_threaded_message_loop) {

messageLoop.reset(new client::MainMessageLoopMultithreadedWin);

} else {

messageLoop.reset(new client::MainMessageLoopStd);

}

context->Initialize(mainArgs, settings, this->browserHandler, sandboxInfo);

client::test_runner::RegisterSchemeHandlers();

context->GetRootWindowManager()->CreateRootWindow(

true,

settings.windowless_rendering_enabled ? true : false,

CefRect(),

std::string());

int result = messageLoop->Run();

context->Shutdown();

messageLoop.reset();

context.reset();

}

I run the application on windows (8.1) and not using the sandbox mode.

Any ideas as for what's happening here and why?

Thanks.


Edit

In my main function I check the process type:

if (MyCefApp::IsCefProcess()) {

return MyCefApp::RunCefProcess();

}

If it's indeed a CEF process (meaning that it's not client::ClientApp::BrowserProcess) then I do:

int MyCefApp::RunCefProcess() {

CefMainArgs mainArgs(GetModuleHandle(nullptr));

void* sandboxInfo = nullptr;

CefRefPtr<CefApp> handler;

switch (GetProcessType()) {

case client::ClientApp::RendererProcess:

handler = new client::ClientAppRenderer();

break;

case client::ClientApp::OtherProcess:

handler = new client::ClientAppOther();

break;

}

return CefExecuteProcess(mainArgs, handler.get(), sandboxInfo);

}

网友答案:

That's a very different startup than the samples I've seen or what we use, but the main thing I don't see is a call to CefExecuteProcess();

CefExecuteProcess is necessary to launch the Renderer and other subprocesses. Without these the pipes that the main browser is trying to contact won't exist. Unless that is being called from one of your other functions your client won't work.

相关阅读:
Top