Page 1 of 1

FPS of OnPaint calls

PostPosted: Fri Jun 18, 2021 2:06 am
by ValentinNikin
Hello!

I want to control Fps of OnPaint calls for Offscreen mode. I.e I want to set up FPS as 25, 30, 60, or something other value. How I can do it?

I have one idea - save buffer from last OnPoint call, and by some timer render this buffer.

I also know about host.Invalidate() function. Seems I can call this function by timer to emulate the FPS value I need. But in this way I need somehow disable automatic OnPaint calls when changes on the page occured.

But, maybe exists more easy way? I'm a beginner in CEF, so please help me.

Re: FPS of OnPaint calls

PostPosted: Fri Jun 18, 2021 2:31 pm
by amaitland
You can set the http://cefsharp.github.io/api/91.1.x/ht ... meRate.htm property when the browser is created. Pass an instance of BrowserSettings into the ChromiumWebBrowser constructor.

You can set the http://cefsharp.github.io/api/91.1.x/ht ... meRate.htm to change the frame rate dynamically. Call http://cefsharp.github.io/api/91.1.x/ht ... erHost.htm to get a IBrowserHost reference.

Re: FPS of OnPaint calls

PostPosted: Fri Jun 18, 2021 4:05 pm
by ValentinNikin
amaitland, thanks for the reply.

But seems this approach not suitable for me. I need render the frames with constant value of the frame rate.
If content on the page is static, this approach doesn't generate OnPaint event.

Let me describe more details of my task.
I have an URL of the some site. I need render the frames of this site with constant predefined frame rate and send this stream of frames by NDI (https://www.ndi.tv/sdk/) to the some clients.
Seems Cef is great solution to render the frames, but I need to send the frames with constant frequency, but OnPaint event doesn't generate when content on the page is static.

Re: FPS of OnPaint calls

PostPosted: Fri Jun 18, 2021 4:29 pm
by amaitland
Best to start with exactly what it is you are trying to achieve.

CEF does have functionality for controlling frame generation, issue https://bitbucket.org/chromiumembedded/ ... s-not-call suggests it's not working currently.

You can test it out for yourself.

http://cefsharp.github.io/api/91.1.x/ht ... rowser.htm
http://cefsharp.github.io/api/91.1.x/ht ... nabled.htm
http://cefsharp.github.io/api/91.1.x/ht ... nFrame.htm

Pass automaticallyCreateBrowser false to the ChromiumWebBrowser constructor.
Pass an instance of http://cefsharp.github.io/api/91.1.x/ht ... owInfo.htm to CreateBrowser
Make sure to call IWindowInfo.SetAsWindowless

https://github.com/cefsharp/CefSharp/bl ... er.cs#L330

If you find problems with this functionality then you can try hacking something together setting the framerate to 1 and calling Invalidate on a timer.

I've not tested either, so no guarantees.

Re: FPS of OnPaint calls

PostPosted: Fri Jun 18, 2021 4:51 pm
by ValentinNikin
Hm... Ok, I will investigate your material. Thank you.