JamesD
JamesD

Reputation: 460

CefSharp.BrowserSubprocess is left running with high CPU if app crashes

I'm making use of the excellent CefSharp project (version 67) to host a browser in our WPF application.

Making use of CefSharp causes child CefSharp.BrowserSubprocess processes to be started, which is by design.

These processes are stopped if I cleanly exit my application and call Cef.Shutdown() as recommended in the documentation:

// Hook up handler earlier in application
Application.Current.Exit += OnApplicationExit;

...

private void OnApplicationExit(object sender, ExitEventArgs e)
{
    if (Dispatcher.CheckAccess() == false)
    {
        Dispatcher.Invoke(() => OnApplicationExit(sender, e));
        return;
    }

    // Stops CefSharp.BrowserSubprocess processes
    Cef.Shutdown();
}

I've noticed that if the application is killed, the CefSharp.BrowserSubprocess responsible for rendering is left running and starts using a lot of CPU and does so indefinitely.

I can add some code to handle this, checking for any orphaned CefSharp.BrowserSubprocess process, and kill them. I'm wondering if there's a better option though?

It would be great if the process itself could perform a period check itself and kill itself, perhaps as a setting.

Upvotes: 0

Views: 7699

Answers (1)

JamesD
JamesD

Reputation: 460

As answered by @amaitland, the following setting should be set to monitor the parent process:

CefSharpSettings.SubprocessExitIfParentProcessClosed = true;

Upvotes: 5

Related Questions