How to wait for the final renderer OnPaint call

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.

How to wait for the final renderer OnPaint call

Postby Robar » Thu Jun 16, 2016 7:44 am

Hi,

I'm currently developing an application which opens a SVG via CEF and takes a screenshot. I'm using C# and the CefGlue binding (v3.2704.1409).

I'm waiting for the OnLoadingStateChange call and as soon as the page is loaded I'm waiting for the first OnPaint call in the RenderHandler. After the first call I save the screenshot as a bitmap.

Unfortunately the first OnPaint call is not always the last one, which leaves me with an incomplete bitmap/screenshot.

How can I tell if the browser is done with the rendering? Is there a way to check if a OnPaint call is the last one?
Last edited by Robar on Tue Jun 21, 2016 7:29 am, edited 1 time in total.
Robar
Newbie
 
Posts: 4
Joined: Mon Jun 06, 2016 2:34 am

Re: How to wait for a finWaiting for renderer completed

Postby magreenblatt » Thu Jun 16, 2016 10:33 am

You can wait some delay that works for you. There is no way to know when a page has stopped painting because the content may be constantly changing (via JS, user interaction, etc).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to wait for a finWaiting for renderer completed

Postby amaitland » Thu Jun 16, 2016 10:44 am

Their are a couple of approaches I've used in the past, the first being In OnLoadingStateChange when IsLoading == false trigger a timer, reset that time every time paint is called (before the trigger), when OnPaint stops being called, the timer stops being reset and the trigger takes a screenshot. Crude, but mostly effective.

Secondly purely for screen shot purposes in combination with a delay I like to drop the WindowlessFrameRate way down. If I'm not particularly worried about performance I'll even drop it to 1fps (You can even count the number of OnPaint calls and capture on the nth call)
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: How to wait for a finWaiting for renderer completed

Postby Robar » Fri Jun 17, 2016 5:19 am

Thanks for your responses. I've already dropped the frame rate to 1fps. And I will now try the approach where I take the screenshot after the nth call.
Robar
Newbie
 
Posts: 4
Joined: Mon Jun 06, 2016 2:34 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 48 guests