OS X OSR - No OnPaint Called
Posted: Thu Jan 03, 2019 3:22 am
Happy New Year Everyone!
Thanks to the "wonderful" folks at Apple dropping 32 bit support, I am replacing Berkelium in my program with CEF. I am using Ogre3d as a rendering middleware, so obviously I used qwertzui11's excellent simplified example for OSR as basis. Practically every other brief OSR example I could find on the web is based off qwertzui's as well. Unfortunately, they're all for Windows or Linux.
I am on OS X 10.12 Sierra using Spotify CEF 3.3538.1852.gcb937fc bin and Xcode 9.2 (9C40b).
The above example worked flawlessly for me on Linux with only minor corrections for newer CEF. But it does not work on OS X. When I run the code on OS X I get several calls to get GetRenderHandler(...) and GetViewRect(...) but no calls to OnPaint(...)
Seeing this thread: viewtopic.php?f=6&t=16371 , I downgraded CEF to Spotify 3.3359 and 3.2704. And had the same results. GetRenderHandler and GetViewRect called, but OnPaint is not.
There are no errors in the logs for 3.3538. Older builds had this complaint:
My full code can be found here (forked from qwertzui11's, cmake probably doesn't work) : https://github.com/VisualEntertainmentA ... es/cef_osr
Relevant pieces are below, I chopped out a lot of the non-CEF stuff:
Main binary:
Helper Program:
Current File Tree for the "App" (unimportant data removed): https://github.com/VisualEntertainmentA ... leTree.txt
I have looked at the CEFClient example, and could not see any major differences other than creating a CefApp and creating a bunch more overrides via that class. I am not sure if it is necessary as they have nothing to do with painting. And it is not needed on Linux. The CEFClient does run. I have enlisted the help of qwertzui11, and he is looking into it. But any additional help would be very much appreciated.
There isn't much in the way of documentation as to what is needed in the Helper program. Perhaps that is the cause? Speaking of documentation, a small note, both the Tutorial and General Useage wikis are missing information about the dylibs being dynamically linked now. May want to work that in there.
Thanks again!
Eric
(Sorry for spelling/grammar, 3am after spending hours on a mac... )
Thanks to the "wonderful" folks at Apple dropping 32 bit support, I am replacing Berkelium in my program with CEF. I am using Ogre3d as a rendering middleware, so obviously I used qwertzui11's excellent simplified example for OSR as basis. Practically every other brief OSR example I could find on the web is based off qwertzui's as well. Unfortunately, they're all for Windows or Linux.
I am on OS X 10.12 Sierra using Spotify CEF 3.3538.1852.gcb937fc bin and Xcode 9.2 (9C40b).
The above example worked flawlessly for me on Linux with only minor corrections for newer CEF. But it does not work on OS X. When I run the code on OS X I get several calls to get GetRenderHandler(...) and GetViewRect(...) but no calls to OnPaint(...)
Seeing this thread: viewtopic.php?f=6&t=16371 , I downgraded CEF to Spotify 3.3359 and 3.2704. And had the same results. GetRenderHandler and GetViewRect called, but OnPaint is not.
There are no errors in the logs for 3.3538. Older builds had this complaint:
- Code: Select all
[1225/092303.885191:ERROR:service_manager_context.cc(258)] Attempting to run unsupported native service: /Users/ericjones/Documents/programming/gearcity/Client-Bin/GearCity.app/Contents/Frameworks/Chromium Embedded Framework.framework/content_renderer.service
My full code can be found here (forked from qwertzui11's, cmake probably doesn't work) : https://github.com/VisualEntertainmentA ... es/cef_osr
Relevant pieces are below, I chopped out a lot of the non-CEF stuff:
Main binary:
- Code: Select all
#include <include/cef_app.h>
#include <include/cef_client.h>
#include <include/cef_render_handler.h>
#include "include/wrapper/cef_library_loader.h"
class RenderHandler : public Ogre::FrameListener, public CefRenderHandler
{
public:
Ogre::TexturePtr m_renderTexture;
RenderHandler(Ogre::TexturePtr texture, Ogre::SceneNode *renderNode)
: m_renderTexture(texture)
{;}
//MAIN LOOP FrameListener interface
public:
bool frameStarted(const Ogre::FrameEvent &evt) override
{
CefDoMessageLoopWork();
return true;
}
// CefRenderHandler interface
public:
bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) override
{
rect = CefRect(0, 0, m_renderTexture->getWidth(), m_renderTexture->getHeight());
printf("\ngetview\n");
return true;
}
void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) override
{
Ogre::HardwarePixelBufferSharedPtr texBuf = m_renderTexture->getBuffer();
texBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD);
memcpy(texBuf->getCurrentLock().data, buffer, width*height*4);
texBuf->unlock();
printf("\nonpaint\n");
}
// CefBase interface
public:
IMPLEMENT_REFCOUNTING(RenderHandler);
};
// for manual render handler
class BrowserClient : public CefClient
{
public:
BrowserClient(RenderHandler *renderHandler)
: m_renderHandler(renderHandler)
{;}
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() override
{
printf("\ngetrenderhandler\n");
return m_renderHandler;
}
CefRefPtr<CefRenderHandler> m_renderHandler;
IMPLEMENT_REFCOUNTING(BrowserClient);
};
int main(int argc, char *argv[])
{
CefScopedLibraryLoader library_loader;
if (!library_loader.LoadInMain())
return 1;
printf("\nstart\n");
CefMainArgs args(argc, argv);
{
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
command_line->InitFromArgv(argc, argv);
int result = CefExecuteProcess(args, nullptr, nullptr);
// checkout CefApp, derive it and set it as second parameter, for more control on
// command args and resources.
if (result >= 0) // child proccess has endend, so exit.
{
return result;
}
if (result == -1)
{
// we are here in the father proccess.
}
}
{
CefSettings settings;
// Tried many of these, Including no_sandbox, windowless_rendering_enabled, etc.
//CefString(&settings.log_file).FromASCII("/Users/ericjones/Documents/programming/gearcity/Client-Bin/debug.log");
settings.log_severity = LOGSEVERITY_VERBOSE;
settings.no_sandbox = true;
settings.windowless_rendering_enabled = true;
printf("\nsettings");
bool result = CefInitialize(args, settings, nullptr, nullptr);
if (!result)
{
// handle error
return -1;
}
}
//init Ogre, etc
RenderHandler* renderHandler;
{
renderHandler = new RenderHandler(renderTexture, renderNode);
renderSystem->addFrameListener(renderHandler);
}
// create browser-window
CefRefPtr<CefBrowser> browser;
CefRefPtr<BrowserClient> browserClient;
{
CefWindowInfo window_info;
CefBrowserSettings browserSettings;
//Passed NSView here as well, didnt' work either...
window_info.SetAsWindowless(nullptr);
browserClient = new BrowserClient(renderHandler);
printf("\n website \n");
browser = CefBrowserHost::CreateBrowserSync(window_info, browserClient.get(), "http://www.google.com", browserSettings, nullptr);
}
// start rendering and calling method RenderHandler::frameStarted / Start Main Loop
{
renderSystem->startRendering();
}
// clean up code on exit...
}
Helper Program:
- Code: Select all
#include "include/cef_app.h"
#include "include/wrapper/cef_library_loader.h"
//#include "include/cef_sandbox_mac.h"
int main(int argc, char* argv[])
{
/*CefScopedSandboxContext sandbox_context;
if(!sandbox_context.Initialize(argc,argv))
return 1;
*/
CefScopedLibraryLoader library_loader;
if (!library_loader.LoadInHelper())
return 1;
CefMainArgs main_args(argc, argv);
//CefRefPtr<ClientApp> app(new ClientApp);
return CefExecuteProcess(main_args,nullptr,nullptr);
}
Current File Tree for the "App" (unimportant data removed): https://github.com/VisualEntertainmentA ... leTree.txt
I have looked at the CEFClient example, and could not see any major differences other than creating a CefApp and creating a bunch more overrides via that class. I am not sure if it is necessary as they have nothing to do with painting. And it is not needed on Linux. The CEFClient does run. I have enlisted the help of qwertzui11, and he is looking into it. But any additional help would be very much appreciated.
There isn't much in the way of documentation as to what is needed in the Helper program. Perhaps that is the cause? Speaking of documentation, a small note, both the Tutorial and General Useage wikis are missing information about the dylibs being dynamically linked now. May want to work that in there.
Thanks again!
Eric
(Sorry for spelling/grammar, 3am after spending hours on a mac... )