Page 1 of 1

CEF doesn't call OnPaint

PostPosted: Sat Dec 23, 2017 9:10 am
by gamelaster
Hello, I'm trying to offscreen rendering CEF (3.3239.1706.gcd33baa_windows64), but I don't know why, OnPaint is not called. GetViewRect is called, OnAfterCreated is called but OnPaint not.
Code:
CEFClient:
Code: Select all
class CEFBrowser : public CefClient, public CefRenderHandler, public CefLifeSpanHandler
{
public:
   CEFBrowser()
   {

   }

   virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override
   {
      return this;
   }

   virtual CefRefPtr<CefRenderHandler> GetRenderHandler() override
   {
      return this;
   }

   virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
   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;


   IMPLEMENT_REFCOUNTING(CEFBrowser);
};

Main app:
Code: Select all
CefMainArgs mainArgs;
   void* sandboxInfo = nullptr;
   CefSettings settings;

   char currentDirectoryStr[FILENAME_MAX];
   GetCurrentDir(currentDirectoryStr, sizeof(currentDirectoryStr));
   std::string currentDirectory = std::string(currentDirectoryStr);

   CefString(&settings.browser_subprocess_path).FromString((currentDirectory + "/cef/modernTVrenderer.exe").c_str());
   CefString(&settings.resources_dir_path).FromString((currentDirectory + "/cef/").c_str());
   CefString(&settings.locales_dir_path).FromString((currentDirectory + "/cef/locales").c_str());
   CefString(&settings.log_file).FromString((currentDirectory + "/cef/cefdebug.log").c_str());
   settings.remote_debugging_port = 9222;

   settings.log_severity = cef_log_severity_t::LOGSEVERITY_ERROR;

   //settings.multi_threaded_message_loop = true;
   settings.windowless_rendering_enabled = true;

   CefInitialize(mainArgs, settings, nullptr, nullptr);
//other code...
   CefRefPtr<CEFBrowser> pWebView = new CEFBrowser();
   CefWindowInfo windowInfo;
   CefBrowserSettings browserSettings;
   //windows
#if _WIN32
   SDL_SysWMinfo wmInfo;
   SDL_VERSION(&wmInfo.version);
   SDL_GetWindowWMInfo(window->GetSDLWindow(), &wmInfo);
#endif
   windowInfo.SetAsWindowless(wmInfo.info.win.window);

   CefBrowserHost::CreateBrowser(windowInfo, pWebView, "http://google.com", browserSettings, nullptr);
//In my main loop
CefDoMessageLoopWork();

Renderer process:
Code: Select all
#include <cef_app.h>
#include <include/cef_client.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
{
   // Structure for passing command-line arguments.
   // The definition of this structure is platform-specific.
   CefMainArgs main_args(hInstance);

   // Optional implementation of the CefApp interface.
   //CefRefPtr<MyApp> app(new MyApp);

   // Execute the sub-process logic. This will block until the sub-process should exit.
   return CefExecuteProcess(main_args, nullptr, nullptr);
}


Any ideas?
Thank you

Re: CEF doesn't call OnPaint

PostPosted: Sat Dec 23, 2017 11:30 am
by Czarek
Call CefBrowser.WasResized after creating browser.

Re: CEF doesn't call OnPaint

PostPosted: Sat Dec 23, 2017 11:35 am
by gamelaster
Czarek wrote:Call CefBrowser.WasResized after creating browser.

Thank you for reply. I tried it in `OnAfterCreated` but OnPaint still not called...

Re: CEF doesn't call OnPaint

PostPosted: Sat Dec 23, 2017 4:10 pm
by Czarek
Are you returning True in GetViewRect?

Re: CEF doesn't call OnPaint

PostPosted: Sun Dec 24, 2017 3:59 am
by gamelaster
Oh I forgotten to post CPP of that CEFBrowser.h
Code: Select all
#include "CEFBrowser.h"

void CEFBrowser::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
   mBrowser = browser;
   mBrowser->GetHost()->WasResized();
}

bool CEFBrowser::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect & rect)
{
   rect = CefRect(0, 0, 500, 500);
   return true;
}

void CEFBrowser::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList & dirtyRects, const void * buffer, int width, int height)
{
   printf("Render\n");
}


So yes, I have return true... I really used all of my ideas and I really don't know why this happening...
Maybe I will build my own CEF build and check in sources why is OnPaint not calling.

EDIT:
I Created CefApp in renderer and find out that OnBrowserCreated is not called or any other function... (I set it as argument in CefExecuteProcess).
I'm really hopeless, any ideas? :-/

BTW: I have one error:
Code: Select all
[1224/130530.574:FATAL:dwrite_font_proxy_init_impl_win.cc(95)] Check failed: fallback_available == base::win::GetVersion() > base::win::VERSION_WIN8 (1 vs. 0)

I tried to solve them but without success

Re: CEF doesn't call OnPaint

PostPosted: Sun Dec 24, 2017 7:39 am
by gamelaster
Fixed, I needed switch from Debug to Release...

Re: CEF doesn't call OnPaint

PostPosted: Fri Jan 26, 2018 4:26 pm
by tabana
I have the same problem. My project was working fine with previous version of CEF. After upgrading to 3.3239.1723, the render doesn't work in debug anymore and I have the same error message.
Code: Select all
[0126/144745.000:FATAL:dwrite_font_proxy_init_impl_win.cc(95)] Check failed: fallback_available == base::win::GetVersion() > base::win::VERSION_WIN8 (1 vs. 0)
[0126/145348.294:WARNING:angle_platform_impl.cc(51)] rx::HLSLCompiler::compileToBinary(228):
C:\fakepath(30,8-58): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
C:\fakepath(35,8-28): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them

Re: CEF doesn't call OnPaint

PostPosted: Thu Feb 01, 2018 10:17 pm
by magreenblatt
See viewtopic.php?f=6&t=14721 for the dwrite_font_proxy_init_impl_win.cc error.

Re: CEF doesn't call OnPaint

PostPosted: Tue Feb 06, 2018 5:01 pm
by tabana
Thank you!