CefInitialize() blowing up

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() blowing up

Postby brnase » Fri Oct 28, 2011 1:23 pm

When I'm calling CefInitialize() there's an exception being thrown and I'm unsure of what might be wrong? The following is from our stack trace, and I'm not even sure this will be of any help?

Code: Select all
File "c:\src\leds\branches\unstable\thirdparty\cef\libcef_dll\wrapper\libcef_dll_wrapper.cc", line 41 in CefInitialize
         File "", line 0 in cef_string_map_free
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in RtlAllocateHeap
         File "", line 0 in RtlDeleteCriticalSection
         File "", line 0 in cef_string_map_free
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_post_data_element_create
         File "", line 0 in cef_post_data_element_create
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_post_data_element_create
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in RtlFreeHeap
         File "", line 0 in cef_post_data_element_create
         File "", line 0 in cef_time_from_doublet
         File "", line 0 in cef_post_data_element_create
       EXCEPTION_BREAKPOINT


Below is the C++ code I'm using:
Code: Select all
CefSettings settings;
settings.multi_threaded_message_loop = false;
   if (!CefInitialize(settings))
   {
      // ... print warning
   }


I'm not sure if I the multi_threaded_message_loop setting is correct for my situation. Although I did try its value as true, the application blew up even sooner without any stack trace.
brnase
Techie
 
Posts: 24
Joined: Mon Oct 24, 2011 2:59 pm

Re: CefInitialize() blowing up

Postby magreenblatt » Fri Oct 28, 2011 1:29 pm

You need to put chrome.pak and the locales folder in the same directory as libcef.dll. You probably had an error about that on the debug console in Visual Studio.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize() blowing up

Postby brnase » Fri Oct 28, 2011 5:01 pm

Thanks on the last bit of information. I forgot to copy over the locale folder files. Once I did that, the initialize worked.

Now, onto my next mess. I'm expecting to see a Google web page as some point in time, but when I call the CreateBrowser function, all I see is a white box on the window where the browser is supposed to be embedded. I noticed that in the cefclient app, that something is being done with a message loop, depending on the multi_threaded_message_loop setting. I'm guessing I need to do something similar, but I think I'm lost here. Also, the browser handler class I created (that inherits from a bunch of CEF handler classes), should I be interacting with that as well to get this to work properly?
brnase
Techie
 
Posts: 24
Joined: Mon Oct 24, 2011 2:59 pm

Re: CefInitialize() blowing up

Postby magreenblatt » Fri Oct 28, 2011 8:35 pm

Are you using a framework like MFC to build your application or strait WinAPI like the cefclient application?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize() blowing up

Postby brnase » Mon Oct 31, 2011 9:01 am

Our project is using Qt (C++) as our framework. Not sure if you're looking for any more information than that?
brnase
Techie
 
Posts: 24
Joined: Mon Oct 24, 2011 2:59 pm

Re: CefInitialize() blowing up

Postby magreenblatt » Mon Oct 31, 2011 9:04 am

You need to integrate CEF with the application message loop. See viewtopic.php?f=6&t=8#p18 for a general description of how this works.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: CefInitialize() blowing up

Postby brnase » Wed Nov 02, 2011 2:46 pm

Thanks for all of your help so far! I appreciate it very much.

I am now able to see web pages in our embedded browser. I have one last question, and it's more about performance and understanding how this even works in the first place more than anything.

Currently, when my application starts, I create a new thread after CefInitialize() with multi_threaded_message_loop = true, and in the run method of this thread the following code is executed:

Code: Select all
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
   TranslateMessage(&msg);
   DispatchMessage(&msg);
}


Now first off, I have no clue how this even allows messages to interact with CEF? Is it because multi_threaded_message_loop is set to true that CEF is smart enough to watch for Windows messages on its own?

Second off, is this the most efficient way for CEF to be embedded in with my application? I did try multi_threaded_message_loop = false and calling CefRunMessageLoop() in the same thread as mentioned above, but I would run into breakpoint issues.
brnase
Techie
 
Posts: 24
Joined: Mon Oct 24, 2011 2:59 pm

Re: CefInitialize() blowing up

Postby magreenblatt » Wed Nov 02, 2011 3:01 pm

When using "multi_threaded_message_loop = true" you don't need to create a separate thread (CEF does this internally). Just call CefShutdown() on the same thread that called CefInitialize() so that CEF can shut down this internal thread and perform other cleanup tasks.

When using "multi_threaded_message_loop = false" you need to integrate CEF's message loop with your application message loop by calling CefRunMessageLoop() or CefDoMessageLoopWork(). CefRunMessageLoop() implements the complete message processing loop for the application and is likely incompatible with Qt's message handling. CefDoMessageLoopWork() is intended for integration with an existing message processing loop and must be called in a timely manner so that CEF can perform message processing. Both CefRunMessageLoop() and CefDoMessageLoopWork() need to be called on the same thread as CefInitialize() and CefShutdown().
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

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