CefSharp.BrowserSubprocess are not closed when ChromiumWebBrowser is Disposed

五迷三道 提交于 2019-12-08 05:18:54

问题


I am using CefSharp 55 in WPF. every time I make a new ChromiumWebBrowser, a new CefSharp.BrowserSubprocess.exe appear in the task manager, which is normal. But they don't disappear when I call Dispose() on a ChromiumWebBrowser. They only disappear when I close the Apllication, propably because at that time I call Cef.Shutdown(). I tried to Force GC after the dispose but i change nothing.

So if the user keep opening and closing tabs in the web browser, we end up with a lot of CefSharp.BrowserSubprocess running which will never be closed exept when the app is closed.

In the constructor of the class extending ChromiumWebBrowser,I do

var requestContextSettings = new RequestContextSettings
{
    PersistSessionCookies = false,
    IgnoreCertificateErrors = true
};

RequestContext = new RequestContext(requestContextSettings);

When I dispose the browser, do

browser.Dispose();
browser.RequestContext.Dispose()

Did I forgot something?

Edit

Apparently it the problem is not limited to CefSharp.BrowserSubprocess. When I dispose a browser playing a youtube video, The sound of the video is still running. It was working before, the video sound was cut after the dispose. Maybe it is a bug in the new version of CefSharp that I updated recently.


回答1:


I found what was the problem. I made an implementation of ILifeSpanHandler where I was returning true in DoClose(...) because I though returning true mean you tell the browser it can close. But in the doc it say to return false to destroy the browser immediatly.

(https://github.com/cefsharp/CefSharp/blob/master/CefSharp/Handler/ILifeSpanHandler.cs)

After doing this, The CefSharp.BrowserSubprocess are closed when I close the corresponding web browser.



来源:https://stackoverflow.com/questions/45919551/cefsharp-browsersubprocess-are-not-closed-when-chromiumwebbrowser-is-disposed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!