How to disable rendering and then re-enable at runtime?

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 disable rendering and then re-enable at runtime?

Postby philip368320 » Tue Sep 10, 2019 7:38 am

Hi,

I wish to stop a browser from rendering so that it doesn't make any effort to call my OnPaint function, at least stop it from doing it for a period of time until I am interested to know what is on that browser screen, at which time I want to re-enable the rendering. Because I want to reduce the CPU usage and not have any rendering going on for some pages which are loading and for a period of time.

Firstly was thinking how to do it with what I currently know, I could inject some javascript into the page to create a black HTML div which covers the entire page, that would black out the page while the page loaded under that div, but that's not going to work for all pages and it won't work when the page goes to another URL, my div will disappear.

Is there any solution for this?

Thanks, Philip
philip368320
Newbie
 
Posts: 2
Joined: Tue Sep 10, 2019 7:22 am

Re: How to disable rendering and then re-enable at runtime?

Postby magreenblatt » Tue Sep 10, 2019 10:36 am

Use the CefBrowserHost::WasHidden method.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to disable rendering and then re-enable at runtime?

Postby philip368320 » Wed Sep 11, 2019 10:05 pm

Thanks a lot, although this method seems more like a query method as its name is WasHidden, but apart from that it does the job well, so I can have many browser now.
philip368320
Newbie
 
Posts: 2
Joined: Tue Sep 10, 2019 7:22 am

Re: How to disable rendering and then re-enable at runtime?

Postby Staxcelrom » Fri Feb 11, 2022 12:04 pm

magreenblatt wrote:Use the CefBrowserHost::WasHidden method.


what is the difference between CefBrowserHost::WasHidden and "Off-Screen Rendering" ?
Staxcelrom
Expert
 
Posts: 206
Joined: Wed Jan 26, 2022 8:20 am

Re: How to disable rendering and then re-enable at runtime?

Postby magreenblatt » Fri Feb 11, 2022 12:13 pm

Staxcelrom wrote:
magreenblatt wrote:Use the CefBrowserHost::WasHidden method.


what is the difference between CefBrowserHost::WasHidden and "Off-Screen Rendering" ?

Please don't post new questions on old threads.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 99 guests