Shutdown all BrowserSubprocess when last browser component is disposed

1,959 views
Skip to first unread message

Kari-Antti Kuosa

unread,
Aug 25, 2015, 7:42:00 AM8/25/15
to CefSharp
Hi,

Is it possible that when the last WPF ChromiumWebBrowser instance is disposed also all processes related to the whole CefSharp are also closed.

-karsu

Alex Maitland

unread,
Aug 25, 2015, 7:50:18 AM8/25/15
to CefSharp
Are you currently calling `Cef.Shutdown()`? Must be called on your applications main thread (typically the same thread you called Cef.Initialize(), if you didn't call Cef.Initialize() explicitly then it will have been called automatically on your UI thread)

Kari-Antti Kuosa

unread,
Aug 27, 2015, 5:49:58 AM8/27/15
to CefSharp
I have not called Cef.Shutfown(), because I have understood that it will shutdown whole Cef infrastructure.

In my application I can have multiple Cef browser components at the same time running and when I close one I'm currently calling ChromiumWebBrowser.Dispose(). Dispose method will close that specific process, but sometimes 1-2 other processes will be there even I do not have any ChromiumWebBrowser instance anymore.

I could maybe call Cef.Shutdown() when I call browser's dispose if there is a way to get number of live BrowserProcesses. I think that extra process what I can see now is RenderProcess maybe?

-karsu

Alex Maitland

unread,
Aug 27, 2015, 6:02:47 AM8/27/15
to CefSharp
For reference, once you call Shutdown there is no way to restart Cef, so only do it when you've finished everything.

As for what type of process, you can look in task manager at the command line arguments, there will be a --type param.

When you call `Cef.Initialize()` one of the first things it does is spawn a gpu-process (assuming you have a graphics card with GPU support).

If you start your app, put a breakpoint on `Cef.Initialize()`, then step over the line, you'll see a new instance of `BrowserProcess` spawned. This is expected and will likely stay live until `Shutdown()` is called.

If you have more than one hanging around, check what type it is.

Kari-Antti Kuosa

unread,
Aug 27, 2015, 6:51:43 AM8/27/15
to CefSharp
First process is gpu-process as you said. The second process which will be there is --type=plugin and it is basically Macromedia Flash.

Is it possible to clean up plugin processes after ChromiumWebBrowser Dispose().

-karsu

Alex Maitland

unread,
Aug 27, 2015, 7:47:42 AM8/27/15
to CefSharp
Not that I'm aware of. There's nothing exposed in CefSharp.

You could get a list of all processes, find the ones with type=plugin and manually close them. Other than that I'm not sure.

Kari-Antti Kuosa

unread,
Aug 27, 2015, 8:10:13 AM8/27/15
to CefSharp
I recognized that the Flash plugin process will be closed automatically when there is no need for it. But it will take little time.

Thanks about your help!

-karsu
Reply all
Reply to author
Forward
0 new messages