无法使用cefclient创建管道

Unable to create pipe using cefclient

本文关键字:创建 管道 cefclient      更新时间:2023-10-16

除了入口点(cefclient_win.cc)外,我在应用程序中几乎是使用cefclient的。
我启动它,出现了一个浏览器窗口,但没有加载任何内容。过了一会儿,刷新按钮启用了,但点击它也没有任何作用。

在日志文件中我得到这个:

[0714/170658:WARNING:ipc_channel_win.cc(276)] Unable to create pipe "\.pipechrome.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 "\.pipechrome.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 "\.pipechrome.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 "\.pipechrome.5432.3.396064" in client mode: The system cannot find the file specified. (0x2)
下面是我启动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();
}

我在windows(8.1)上运行应用程序,而不是使用沙盒模式。
你知道这里发生了什么,为什么吗?
谢谢。


编辑

在main函数中,我检查进程类型:

if (MyCefApp::IsCefProcess()) {
   return MyCefApp::RunCefProcess();
}

如果它确实是一个CEF进程(这意味着它不是client::ClientApp::BrowserProcess),那么我做:

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);
}

这是一个与我所见过的或我们使用的示例非常不同的启动,但我没有看到的主要内容是调用CefExecuteProcess();

CefExecuteProcess是启动Renderer和其他子进程所必需的。没有这些,主浏览器试图连接的管道将不存在。除非从您的其他函数之一调用,否则您的客户端将无法工作