[Solved] Cannot get any multi-process code to load a page.

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.

[Solved] Cannot get any multi-process code to load a page.

Postby ScottD » Sat Feb 04, 2017 6:22 pm

This is kind of a continuation of my posts under http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11415.

After trying a separate subprocess executable, I decided to just see if I could get a single executable to work. Like my cefRunner.exe rewrite in the above thread, I re-did my main program to pass an hInst into CefMainArgs to get the command line arguments.

At the moment, my code is way too large to post. The symptom is, if I set single_process to true, it will load and render the page. This is bad as single_process is inefficient and unsupported (and crashes on exit). However, using one binary or multiple binaries, I get nothing more than a couple calls to OnLoadingStateChange. I never see an OnLoadStart, OnLoadEnd, OnPaint, or much else. No render thread gets created.

I'm so confused. I'm going to try and boil this down into something I can pastebin.
Last edited by ScottD on Sat Mar 18, 2017 5:22 pm, edited 1 time in total.
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby ScottD » Sat Feb 04, 2017 7:13 pm

Ok! That was easier than I expected. Here's my broken mess. It is built against cef_binary_3.2883.1553.g80bd606_windows64.

Browser.h
Code: Select all
#ifndef BROWSER_H
#define BROWSER_H

#ifdef _WIN32
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif

#include "cef_app.h"
#include "cef_client.h"
#include "cef_render_handler.h"
#include "wrapper/cef_helpers.h"


// --- AppHandler


class AppHandler : public CefApp, public CefRenderProcessHandler {

   public:
      virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE;
      virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;

   IMPLEMENT_REFCOUNTING(AppHandler)
};


// --- BrowserHandler

class BrowserHandler :
      public CefBrowserProcessHandler,
      public CefRenderProcessHandler,
      public CefClient,
      public CefLifeSpanHandler,
      public CefLoadHandler,
      public CefRequestHandler,
      public CefDisplayHandler,
      public CefRenderHandler,
      public CefKeyboardHandler {

   public:
      // Singleton Access
      static CefRefPtr<BrowserHandler> instance();
      // Cef Handler Methods
      virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE;
      virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
      virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE;
      virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
      virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
      virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE;
      // CefLoadHandler
      virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) OVERRIDE;
      virtual void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::ErrorCode errorCode, const CefString &errorText, const CefString &failedUrl) OVERRIDE;
      virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE;
      virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::TransitionType transitionType) OVERRIDE;
      // CefRenderHandler (not all methods implemented)
      virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) OVERRIDE;
      virtual void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) OVERRIDE;
      // CefKeyboardHandler
      virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent &event, CefEventHandle osEvent) OVERRIDE;
      virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent &event, CefEventHandle osEvent, bool *isKeyboardShortcut) OVERRIDE;
      // CefLifeSpanHandler
      virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString &targetUrl, const CefString &targetFrameName, CefLifeSpanHandler::WindowOpenDisposition targetDisposition, bool userGesture, const CefPopupFeatures &popupFeatures, CefWindowInfo &windowInfo, CefRefPtr<CefClient> &client, CefBrowserSettings &settings, bool *noJavascriptAccess) OVERRIDE;
      // CefBrowserProcessHandler
      virtual void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info) OVERRIDE;
      // CefRenderProcessHandler
      virtual bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRenderProcessHandler::NavigationType navigationType, bool isRedirect) OVERRIDE;
      virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
      virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
      virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
      virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extraInfo) OVERRIDE;
      virtual void OnUncaughtException(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Exception> exception, CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
      virtual void OnWebKitInitialized() OVERRIDE;
      // CefClient / CefRenderProcessHandler
      virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) OVERRIDE;
      // CefDisplayHandler (not implemented at all)
      // CefBrowserProcessHandler (not implemented at all)
      // CefRequestHandler (not implemented at all)

   private:
      static CefRefPtr<BrowserHandler> _browserHandlerInstance;

   IMPLEMENT_REFCOUNTING(BrowserHandler)
   IMPLEMENT_LOCKING(BrowserHandler)
};


// --- Browser


class Browser {

   public:
      // Constructor / Destructor
      Browser(unsigned int width = 0, unsigned int height = 0, std::string url = "about:blank");
      ~Browser();

      static bool shutdown();
      static bool startup(HINSTANCE hInst);
      static bool update();

   private:
      static CefRefPtr<AppHandler>     _appHandlerInstance;
      static CefRefPtr<BrowserHandler> _browserHandlerInstance;
      static CefMainArgs               _cefMainArgs;
      static CefSettings               _cefSettings;

      CefRefPtr<CefBrowser> _cefBrowser;
      CefWindowInfo         _windowInfo;
      CefBrowserSettings    _browserSettings;
};

#endif // BROWSER_H


Browser.cpp
Code: Select all
#include "Browser.h"

#include <string>
#include <iostream>


// For readability.
#define STATIC
#define PUBLIC
#define PRIVATE
#define CONSTRUCTOR
#define DESTRUCTOR
#define VIRTUAL

#define UNUSED (void)


// Replacement for my logger.
#define DEBUG "DEBUG"
#define FATAL "FATAL"
#define SAY(l, m) std::cout << "[" << l << "]  " << m << std::endl;


// --- AppHandler


PUBLIC CefRefPtr<CefBrowserProcessHandler> AppHandler::GetBrowserProcessHandler() {
   SAY(DEBUG, "===== GetRenderProcessHandler()");
   return BrowserHandler::instance().get();
}


PUBLIC CefRefPtr<CefRenderProcessHandler> AppHandler::GetRenderProcessHandler() {
   SAY(DEBUG, "===== GetRenderProcessHandler()");
   return BrowserHandler::instance().get();
}


// --- BrowserHandler


STATIC PRIVATE CefRefPtr<BrowserHandler> BrowserHandler::_browserHandlerInstance = nullptr;


STATIC PUBLIC CefRefPtr<BrowserHandler> BrowserHandler::instance() {
   if (!_browserHandlerInstance) {
      _browserHandlerInstance = new BrowserHandler();
   }
   return _browserHandlerInstance;
}


VIRTUAL PUBLIC CefRefPtr<CefLifeSpanHandler> BrowserHandler::GetLifeSpanHandler() {
   SAY(DEBUG, "===== GetLifeSpanHandler()");
   return this;
}


VIRTUAL PUBLIC CefRefPtr<CefLoadHandler> BrowserHandler::GetLoadHandler() {
   SAY(DEBUG, "===== GetLoadHandler()");
   return this;
}


VIRTUAL PUBLIC CefRefPtr<CefRequestHandler> BrowserHandler::GetRequestHandler() {
   SAY(DEBUG, "===== GetRequestHandler()");
   return this;
}


VIRTUAL PUBLIC CefRefPtr<CefDisplayHandler> BrowserHandler::GetDisplayHandler() {
   SAY(DEBUG, "===== GetDisplayHandler()");
   return this;
}


VIRTUAL PUBLIC CefRefPtr<CefRenderHandler> BrowserHandler::GetRenderHandler() {
   SAY(DEBUG, "===== GetRenderHandler()");
   return this;
}


VIRTUAL PUBLIC CefRefPtr<CefKeyboardHandler> BrowserHandler::GetKeyboardHandler() {
   SAY(DEBUG, "===== GetKeyboardHandler()");
   return this;
}


VIRTUAL PUBLIC void BrowserHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) {
   SAY(DEBUG, "===== OnLoadEnd()");
}


VIRTUAL PUBLIC void BrowserHandler::OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::ErrorCode errorCode, const CefString &errorText, const CefString &failedUrl) {
   SAY(DEBUG, "===== OnLoadError()");
}


VIRTUAL PUBLIC void BrowserHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool isLoading, bool canGoBack, bool canGoForward) {
   SAY(DEBUG, "===== OnLoadingStateChange()");
}


VIRTUAL PUBLIC void BrowserHandler::OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::TransitionType transitionType) {
   SAY(DEBUG, "===== OnLoadStart()");
}


VIRTUAL PUBLIC bool BrowserHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) {
   SAY(DEBUG, "===== GetViewRect()");
   rect = CefRect(0, 0, 1024, 1024);  //***TODO*** Fake
   return true;
}


VIRTUAL PUBLIC void BrowserHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) {
   SAY(DEBUG, "===== OnPaint()");
}


VIRTUAL PUBLIC bool BrowserHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent &event, CefEventHandle osEvent) {
   SAY(DEBUG, "===== OnKeyEvent()");
   return false; // Event not handled.
}


VIRTUAL PUBLIC bool BrowserHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent &event, CefEventHandle osEvent, bool *isKeyboardShortcut) {
   SAY(DEBUG, "===== OnPreKeyEvent()");
   return false; // Event not handled.
}


VIRTUAL PUBLIC bool BrowserHandler::DoClose(CefRefPtr<CefBrowser> browser) {
   SAY(DEBUG, "===== DoClose()");
   return false;  // With no window rendering, destroys browser immediately.
}


VIRTUAL PUBLIC void BrowserHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
   SAY(DEBUG, "===== OnAfterCreated()");
}


VIRTUAL PUBLIC void BrowserHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
   SAY(DEBUG, "===== OnBeforeClose()");
}


VIRTUAL PUBLIC bool BrowserHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString &targetUrl, const CefString &targetFrameName, CefLifeSpanHandler::WindowOpenDisposition targetDisposition, bool userGesture, const CefPopupFeatures &popupFeatures, CefWindowInfo &windowInfo, CefRefPtr<CefClient> &client, CefBrowserSettings &settings, bool *noJavascriptAccess) {
   SAY(DEBUG, "===== OnBeforePopup()");
   return true;  // Cancel popup creation.  For now.
}


VIRTUAL PUBLIC void BrowserHandler::OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info) {
   SAY(DEBUG, "===== OnRenderProcessThreadCreated()");
}


VIRTUAL PUBLIC bool BrowserHandler::OnBeforeNavigation(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRenderProcessHandler::NavigationType navigationType, bool isRedirect) {
   SAY(DEBUG, "===== OnBeforeNavigation()");
   return false;  // Returning 'true' cancels navigation.
}

VIRTUAL PUBLIC void BrowserHandler::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
   SAY(DEBUG, "===== OnBrowserCreated()");
}


VIRTUAL PUBLIC void BrowserHandler::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
   SAY(DEBUG, "===== OnBrowserDestroyed()");
}


VIRTUAL PUBLIC void BrowserHandler::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
   SAY(DEBUG, "===== OnContextCreated()");
}


VIRTUAL PUBLIC void BrowserHandler::OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
   SAY(DEBUG, "===== OnContextReleased()");
}


VIRTUAL PUBLIC void BrowserHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) {
   SAY(DEBUG, "===== OnFocusedNodeChanged()");
}


VIRTUAL PUBLIC void BrowserHandler::OnRenderThreadCreated(CefRefPtr<CefListValue> extraInfo) {
   SAY(DEBUG, "===== OnRenderThreadCreated()");
}


VIRTUAL PUBLIC void BrowserHandler::OnUncaughtException(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Exception> exception, CefRefPtr<CefV8StackTrace> stackTrace) {
   SAY(DEBUG, "===== OnUncaughtException()");
}


VIRTUAL PUBLIC void BrowserHandler::OnWebKitInitialized() {
   SAY(DEBUG, "===== OnWebKitInitialized()");
}


VIRTUAL PUBLIC bool BrowserHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) {
   SAY(DEBUG, "===== OnProcessMessageReceived()");
   return false;
}


// --- Browser


STATIC PRIVATE CefRefPtr<AppHandler>     Browser::_appHandlerInstance = nullptr;
STATIC PRIVATE CefMainArgs               Browser::_cefMainArgs;
STATIC PRIVATE CefSettings               Browser::_cefSettings;


STATIC PUBLIC bool Browser::shutdown() {
   SAY(DEBUG, "Stopping CEF.");
   CefDoMessageLoopWork();
   CefDoMessageLoopWork();
   CefDoMessageLoopWork();
   CefShutdown();
   return true;
}


STATIC PUBLIC bool Browser::startup(HINSTANCE hInst) {

   SAY(DEBUG, "Starting CEF.");

   _cefMainArgs = CefMainArgs(hInst);
   _appHandlerInstance = new AppHandler();

   _cefSettings.single_process = false;
   _cefSettings.no_sandbox = true;
   _cefSettings.multi_threaded_message_loop = false;
   _cefSettings.command_line_args_disabled = false;
   _cefSettings.windowless_rendering_enabled = true;

   int cefSubProcessExit = CefExecuteProcess(_cefMainArgs, _appHandlerInstance.get(), nullptr);
   if (cefSubProcessExit >= 0) exit(cefSubProcessExit);

   bool cefInit = CefInitialize(_cefMainArgs, _cefSettings, _appHandlerInstance.get(), nullptr);
   if (!cefInit) {
      SAY(FATAL, "Failed to initialize CEF.");
      exit(-1);
   }

   return true;
}


STATIC PUBLIC bool Browser::update() {
   CefDoMessageLoopWork();
   return true;
}


PUBLIC CONSTRUCTOR Browser::Browser(unsigned int width, unsigned int height, std::string url) {

   CefString cefUrl(url);

   _windowInfo.SetAsWindowless(nullptr, false);
   _cefBrowser = CefBrowserHost::CreateBrowserSync(_windowInfo, BrowserHandler::instance().get(), cefUrl, _browserSettings, nullptr);
}


PUBLIC DESTRUCTOR Browser::~Browser() {
   _cefBrowser = nullptr;
}


Test.cpp
Code: Select all
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "Browser.h"


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow) {

   Browser::startup(hInst);
   Browser *test = new Browser(1024, 1024, "http://google.com");

   // Going to have to kill this to exit.
   while (Browser::update());

   Browser::shutdown();

   return 0;
}


Running with _cefSettings.single_process = false; results in:
Code: Select all
[DEBUG]  Starting CEF.
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetLifeSpanHandler()
[DEBUG]  ===== OnAfterCreated()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadingStateChange()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadingStateChange()
[DEBUG]  ===== GetDisplayHandler()
[DEBUG]  ===== GetRequestHandler()


While _cefSettings.single_process = true; produces:
Code: Select all
[DEBUG]  Starting CEF.
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetLifeSpanHandler()
[DEBUG]  ===== OnAfterCreated()
[0205/000539:ERROR:proxy_service_factory.cc(126)] Cannot use V8 Proxy resolver in single process mode.
[0205/000539:INFO:dxva_video_decode_accelerator_win.cc(1078)] mf.dll is required for hardware video decoding
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadingStateChange()
[0205/000539:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel.
[0205/000539:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel.
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnRenderProcessThreadCreated()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnRenderThreadCreated()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnWebKitInitialized()
[0205/000539:WARNING:histograms.cc(40)] Started multiple compositor clients (Browser, Renderer) in one process. Some metrics will be disabled.
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnBrowserCreated()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnBeforeNavigation()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadingStateChange()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== GetViewRect()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== OnPaint()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnBeforeNavigation()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnBeforeNavigation()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadStart()
[DEBUG]  ===== GetLoadHandler()
[DEBUG]  ===== OnLoadStart()
[DEBUG]  ===== GetDisplayHandler()
[DEBUG]  ===== GetDisplayHandler()
[DEBUG]  ===== GetDisplayHandler()
[DEBUG]  ===== GetRenderProcessHandler()
[DEBUG]  ===== OnContextCreated()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== OnPaint()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== OnPaint()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== OnPaint()
[DEBUG]  ===== GetRenderHandler()
[DEBUG]  ===== OnPaint()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()
[DEBUG]  ===== GetRequestHandler()


...and continues to produce output until you stop it.

This latest code is based off of https://github.com/omnomasaur/web_system which so far has made the most sense to me. However, my previous attempts have all done the same thing.

What in the world am I doing wrong?
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby Czarek » Sun Feb 05, 2017 3:06 am

You have to run a proper message loop. Calling CefDoMessageLoopWork() in a while loop doesn't seem to be a correct usage. See cefsimple/cefclient examples.
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: Cannot get any multi-process code to load a page.

Postby amaitland » Sun Feb 05, 2017 6:47 pm

Look at CefRunMessageLoop() it might better suite your requirements

apidocs3/projects/(default)/(_globals).html#CefRunMessageLoop()
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Cannot get any multi-process code to load a page.

Postby ScottD » Mon Feb 06, 2017 8:07 pm

Thank you for the advice. However, I need to integrate with another message loop. Can I just put the CEF3 one in it's own thread and let it run?

(The posted code is a super stripped down version of my whole application.)
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby amaitland » Mon Feb 06, 2017 8:19 pm

On Windows you can use multi threaded message loop.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Cannot get any multi-process code to load a page.

Postby ScottD » Mon Feb 06, 2017 8:35 pm

Changing to CefDoMessageLoop from repeatedly calling CefDoMessageLoopWork didn't change anything. :sad:
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby ScottD » Mon Feb 06, 2017 8:48 pm

Czarek wrote:You have to run a proper message loop. Calling CefDoMessageLoopWork() in a while loop doesn't seem to be a correct usage. See cefsimple/cefclient examples.


I'll look into this. I'm only a Windows coder under duress. Right now, other than using WinMain as an entry point, there's no Windows specific code in my project. Lack of a proper Windows message loop may be a Bad Thing (tm).
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby ScottD » Tue Feb 07, 2017 3:30 pm

ScottD wrote:I'll look into this. I'm only a Windows coder under duress. Right now, other than using WinMain as an entry point, there's no Windows specific code in my project. Lack of a proper Windows message loop may be a Bad Thing (tm).


I tried it. Nothing. Same results. Attempting to use multi_threaded_message_loop crashes with a "wrong thread" error.

Latest code...

Test.cpp
Code: Select all
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "Browser.h"


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow) {

   Browser::startup(hInst);
   Browser *test = new Browser(1024, 1024, "http://google.com");

   // Going to have to kill this to exit.
   bool running = true;
   MSG msg;
   BOOL bRet;
   while (running) {
      if (!Browser::update()) running = false;

      bRet = GetMessage(&msg, NULL, 0, 0);
      if (bRet > 0) {
         // (bRet > 0 indicates a message that must be processed.)
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      } else if (bRet < 0) {
         // (bRet == -1 indicates an error.)
         // Handle or log the error; possibly exit.
         // ...
      } else {
         // (bRet == 0 indicates "exit program".)
         running = false;
      }
   }

   Browser::shutdown();

   return 0;
}


The Beatles wrote:Help me if you can, I'm feeling down
And I do appreciate you being 'round
Help me get my feet back on the ground
Won't you please, please help me?
ScottD
Techie
 
Posts: 20
Joined: Mon Jan 30, 2017 5:22 pm
Location: Smithton, IL, USA, Earth

Re: Cannot get any multi-process code to load a page.

Postby amaitland » Tue Feb 07, 2017 4:08 pm

Your code doesn't make a whole lot of sense. How about you start at the beginning?

What are you trying to achieve? What platform are you using? What frameworks/technologies?
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Next

Return to Support Forum

Who is online

Users browsing this forum: Biohazard and 18 guests