How to set or choose the right chromium build flags?

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 set or choose the right chromium build flags?

Postby terryzlf » Sun Jul 04, 2021 10:33 pm

How to set or choose the right chromium build flags? Why high cpu-gpu usage.

I built cef 32 bit windows version from souce without change the default build setting.
But when I ran it, I found different behavior between my build and the chrome.

In chrome: Ex. Open a 'https://alteredqualia.com/three/examples/webgl_terrain_dynamic.html' 。
When I switch to anthor tab, hide this high gpu page, the system cpu gpu usage goes down immediately.
Same result was seen when I minimize the Chrome.
And same result was seen when I moved any other app`s window on the Chrome, the Chrome seems to stop rendering if whole Chrome is not visible.

It seems the browser redering is stopped. It really saved a lot of cpu-gpu usage!

But in my app, I can not achieve the same good cpu-gpu usage effect.

I also tried windowless osr, but failed.
I think this maybe the build setting error when I build from souce .

Please help.
Best wishes!
terryzlf
Newbie
 
Posts: 4
Joined: Sun Jul 04, 2021 10:04 pm

Re: How to set or choose the right chromium build flags?

Postby magreenblatt » Sun Jul 04, 2021 11:06 pm

What CEF version? Have you tested with the CEF sample apps? You can also try running them with the “--use-views” and “--enable-chrome-runtime” command-line flags. See also https://chromium.googlesource.com/chrom ... racking.md which is only supported with Views/Chrome.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: How to set or choose the right chromium build flags?

Postby terryzlf » Thu Jul 08, 2021 7:23 am

magreenblatt wrote:What CEF version? Have you tested with the CEF sample apps? You can also try running them with the “--use-views” and “--enable-chrome-runtime” command-line flags. See also https://chromium.googlesource.com/chrom ... racking.md which is only supported with Views/Chrome.


Thank you for your reply!

After some test, I found that my question is not accurate. I am sorry!
Actually the CEF sample demo, can drop cpu-gpu usage when I minimized the window.

But in my QT based application, it seems not work. I also using tabs to show hide many browser instances. The cpu-gpu is high!
I found that there is an api -- wasHidden , can be used in windowless based integration, that may be a solution. But it seems more difficult to use cef, comparing to window based version.
terryzlf
Newbie
 
Posts: 4
Joined: Sun Jul 04, 2021 10:04 pm

Re: How to set or choose the right chromium build flags?

Postby magreenblatt » Thu Jul 08, 2021 11:49 am

You need to set the browser window size to 0x0 when it’s hidden. See this code in cefclient.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: How to set or choose the right chromium build flags?

Postby terryzlf » Thu Jul 08, 2021 9:52 pm

magreenblatt wrote:You need to set the browser window size to 0x0 when it’s hidden. See this code in cefclient.


I tried it. It seems not work.

Here is my code:
Code: Select all

void KKBrowserPage::showEvent(QShowEvent* event) {
    //QWidget::showEvent(event);
   if (!m_pBrowser)
      return;
   bool bWindowRending = m_pBrowser->GetHost()->IsWindowRenderingDisabled();
   m_pBrowser->GetHost()->WasHidden(false);
    // Give focus to the browser.
    m_pBrowser->GetHost()->SendFocusEvent(true);

    m_pBrowser->GetHost()->Invalidate(PET_POPUP);

    QRect rect = ui.uiBrowserRenderView->rect();
    SetBrowserPos(rect);//set back to real size --> this may cause repaint?

    qDebug() << "showEvent:" << m_pBrowser->GetHost()->GetWindowHandle() << " pBrowser:" << m_pBrowser->GetIdentifier();
    ::BringWindowToTop(m_pBrowser->GetHost()->GetWindowHandle());

}

void KKBrowserPage::hideEvent(QHideEvent *event) {
    //QWidget::hideEvent(event);
   if (!m_pBrowser)
      return;
   m_pBrowser->GetHost()->WasHidden(true);
    m_pBrowser->GetHost()->SendFocusEvent(false);

    qDebug() << "hideEvent:" << m_pBrowser->GetHost()->GetWindowHandle() << " pBrowser:" << m_pBrowser->GetIdentifier();

    ::SetWindowPos(m_pBrowser->GetHost()->GetWindowHandle(), nullptr, 0, 0, 1, 1,
        SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); //set to a small size
}

terryzlf
Newbie
 
Posts: 4
Joined: Sun Jul 04, 2021 10:04 pm

Re: How to set or choose the right chromium build flags?

Postby magreenblatt » Thu Jul 08, 2021 10:13 pm

You’re setting the size to 1x1, not 0x0. You also need to restore the previous size in the show method.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: How to set or choose the right chromium build flags?

Postby terryzlf » Fri Jul 09, 2021 5:05 am

magreenblatt wrote:You’re setting the size to 1x1, not 0x0. You also need to restore the previous size in the show method.


Yes, it works when not using windowless. And the cpu-gpu usage is reduced.
I will use this solution.

Thanks a lot!
You are great!
terryzlf
Newbie
 
Posts: 4
Joined: Sun Jul 04, 2021 10:04 pm


Return to Support Forum

Who is online

Users browsing this forum: cybersight and 39 guests