Chromium


#1

Chromium Embedded framework has two methods, CefDoMessageLoopWork and CefRunMessageLoop. Using CefRunMessageLoop it is pretty easy to bring up a chromium window in JUCE but this controls the message loop. According to their docs...

CefRunMessageLoop 
///
// Run the CEF message loop. Use this function instead of an application-
// provided message loop to get the best balance between performance and CPU
// usage. This function should only be called on the main application thread and
// only if CefInitialize() is called with a
// CefSettings.multi_threaded_message_loop value of false. This function will
// block until a quit message is received by the system.
///
 

CefDoMessageLoopWork

///
// Perform a single iteration of CEF message loop processing. This function is
// used to integrate the CEF message loop into an existing application message
// loop. Care must be taken to balance performance against excessive CPU usage.
// This function should only be called on the main application thread and only
// if CefInitialize() is called with a CefSettings.multi_threaded_message_loop
// value of false. This function will not block.
///

So what I am trying to do is open up the CEF window from a JUCE button and then call CefDoMessageLoopWork on the message loop. Is this right and how exactly do I do that?

Bob

 


#2

FYI I am on Windows 7 using cef_binary_3.1750.1738_windows32.

This is what I tried. Created a component that extends Thread.

Set multi_threaded_message_loop = false; at init.

Call CefDoMessageLoopWork(); from run().

App crashes when CefDoMessageLoopWork(); is called.


#3

Well, continuing on my journey of crashes I found that there is a log file being created by CEF. In it I see this error message.

[0306/185629:ERROR:singleton_hwnd.cc(43)] Cannot create windows on non-UI thread!

Anybody have any idea about this?

 

 

 


#4

When you derive from and use Thread JUCE creates a background thread. Windows only allows GUI constructs from the main thread. You could try deriving a component from Timer and periodically invoke on that, but the performance might be too slow.

I think you might have to dig deeper into message dispatching.

Good luck!

-jjf


#5

That worked! Not sure how efficient it is but it isn't crashing. I extended Timer and called CefDoMessageLoopWork(); in timerCallback().

I set startTimer(10); I will keep testing and see if it slows down the app. Thanks for the help.