How to kill CEF subprocess?

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 kill CEF subprocess?

Postby Yukigaru » Fri Sep 01, 2017 8:02 am

Hi, in a PC game I have ingame browser used for news, virtual currency shop and social networks. It's built with quite fresh update of Chromium Embedded Framework. The problem is when I open a browser window (website is working fine there) and then close, for certain websites CEF sub-process doesn't finish. I also may continue hearing audio, if it was Youtube video, for example. I use offscreen rendering, other native windows are not created, only subprocesses. To close the browser window I remove all references to CefBrowser and call:
Code: Select all
    m_browser->GetHost()->CloseBrowser(true);

I also tried other ways to close/destroy/finalize that render subprocess, such as loading 'about:blank' before closing, but that was no help: process stayed awake, audio continued playing.
Important note: it happens only on certain websites, which I suppose use some feature, that others don't. When I tried to disable JavaScript in CEF settings, the bug disappeared, but I need JS.

1. Is there a way to force kill browser subprocess? (Notice that GetWindowHandle returns 0, because it does not have a window)
2. Is there another way to correctly terminate browser which I don't know?
3. What feature of the websites may cause such bug?

Thank you!

CEF runtime configuration: multi-process, single threaded message loop, with another subprocess path, windowless rendering, no sandbox.
PC configuration: OS Windows 8, VS 2010, Chromium Embedded Framework version 3.3071, build 1649, C++ language.
Yukigaru
Newbie
 
Posts: 5
Joined: Tue Jul 18, 2017 7:40 am

Re: How to kill CEF subprocess?

Postby Czarek » Fri Sep 01, 2017 12:48 pm

Can you reproduce the issue in cefclient (run with --off-screen-rendering-enabled flag)? Are you freeing all CEF references to all kinds of objects related to that browser?

If it's just about terminating these zombie processes then you can do that using win32 api. You first need to identify a process for a browser and you can do that in a CEF API callback that is called when browser is created. Sometimes multiple browsers may be hosted in a single Renderer process and to avoid that you should provide unique request contexts during browser creation so that they are not shared.
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: How to kill CEF subprocess?

Postby Yukigaru » Mon Sep 04, 2017 2:51 am

Thanks for the answer!

Czarek wrote:Can you reproduce the issue in cefclient (run with --off-screen-rendering-enabled flag)? Are you freeing all CEF references to all kinds of objects related to that browser?

It's quite unclear if it's reproduced in cefclient or not, because when I start it creates three processes at once. Then when I open "Tests -> New Window" sometimes it creates a new process, sometimes not. Sometimes it finishes a process after clicking [X], sometimes not.

Regarding references: yes, I'm freeing all refs. Checked twice.
Yukigaru
Newbie
 
Posts: 5
Joined: Tue Jul 18, 2017 7:40 am

Re: How to kill CEF subprocess?

Postby Yukigaru » Mon Sep 04, 2017 3:10 am

Czarek wrote:If it's just about terminating these zombie processes then you can do that using win32 api. You first need to identify a process for a browser and you can do that in a CEF API callback that is called when browser is created. Sometimes multiple browsers may be hosted in a single Renderer process and to avoid that you should provide unique request contexts during browser creation so that they are not shared.

What's the method name? I could only find window handle, but not process id.
Yukigaru
Newbie
 
Posts: 5
Joined: Tue Jul 18, 2017 7:40 am

Re: How to kill CEF subprocess?

Postby Czarek » Mon Sep 04, 2017 8:13 am

In CefRenderProcessHandler::OnBrowserCreated call GetCurrentProcessId:
https://msdn.microsoft.com/pl-pl/librar ... 80(v=vs.85).aspx
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


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 66 guests