Closed kkwpsv closed 3 years ago
Pull requests welcome.
For now we'll just leave the GC
to take care of the LifeSpanHandler
property, it's unlikely this will cause any leaks.
It sounds like the reference to ChromiumWebBrowser
in ClientAdapter::DoClose
is still valid, no report of exception, so hopefully this resolves the problem.
If the problem still occurs I'll leave you to debug further.
Sorry for no reply for so long.
I have debugged this. And found two solution:
LifeSpanHandler
to null should solve this. But neither of these two methods directly solve the thread timing issues. So i didn't make a pull request at that time and make this issue to know if there is a more direct solution.
Setting LifeSpanHandler
to null should not cause any leaks. And I have checked the reference to ChromiumWebBrowser
is still valid. And i think this solution is also acceptable.
Thanks for the feedback 👍
Change is included in https://www.nuget.org/packages/CefSharp.Wpf.HwndHost/89.0.170
When closing a
ChromiumWebBrowser
, ClientAdapter::DoClose is called at 'CrBrowserMain' thread and ILifeSpanHandler is set to null at main thread.ILifeSpanHandler.DoClose
may not be called becauseILifeSpanHandler
has been set to null. This may lead to that the parent window ofChromiumWebBrowser
will be closed. WhenChromiumWebBrowser
is visible, this has no special effect. Beacuse it doesn't have parent now. WhenChromiumWebBrowser
is not visible, it has been reparented toSystemResourceNotifyWindow
byHwndHost
. And all hiddenHwndHost
is reparented to is. This will cause all hiddenHwndHost
is closed.