CEF doesn't call OnPaint

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.

CEF doesn't call OnPaint

Postby gamelaster » Sat Dec 23, 2017 9:10 am

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
Last edited by gamelaster on Sat Dec 23, 2017 11:55 am, edited 1 time in total.
gamelaster
Newbie
 
Posts: 5
Joined: Tue Jul 04, 2017 3:01 pm

Re: CEF doesn't call OnPaint

Postby Czarek » Sat Dec 23, 2017 11:30 am

Call CefBrowser.WasResized after creating browser.
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: CEF doesn't call OnPaint

Postby gamelaster » Sat Dec 23, 2017 11:35 am

Czarek wrote:Call CefBrowser.WasResized after creating browser.

Thank you for reply. I tried it in `OnAfterCreated` but OnPaint still not called...
gamelaster
Newbie
 
Posts: 5
Joined: Tue Jul 04, 2017 3:01 pm

Re: CEF doesn't call OnPaint

Postby Czarek » Sat Dec 23, 2017 4:10 pm

Are you returning True in GetViewRect?
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: CEF doesn't call OnPaint

Postby gamelaster » Sun Dec 24, 2017 3:59 am

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
gamelaster
Newbie
 
Posts: 5
Joined: Tue Jul 04, 2017 3:01 pm

Re: CEF doesn't call OnPaint

Postby gamelaster » Sun Dec 24, 2017 7:39 am

Fixed, I needed switch from Debug to Release...
gamelaster
Newbie
 
Posts: 5
Joined: Tue Jul 04, 2017 3:01 pm

Re: CEF doesn't call OnPaint

Postby tabana » Fri Jan 26, 2018 4:26 pm

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
tabana
Newbie
 
Posts: 2
Joined: Fri Jan 26, 2018 3:24 pm

Re: CEF doesn't call OnPaint

Postby magreenblatt » Thu Feb 01, 2018 10:17 pm

See viewtopic.php?f=6&t=14721 for the dwrite_font_proxy_init_impl_win.cc error.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: CEF doesn't call OnPaint

Postby tabana » Tue Feb 06, 2018 5:01 pm

Thank you!
tabana
Newbie
 
Posts: 2
Joined: Fri Jan 26, 2018 3:24 pm


Return to Support Forum

Who is online

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