WcfEnabledSubProcess - OnBrowserDestroyed add null checks and log msg if WCF was null

It's likely the WCF host didn't start and some break points should be added in ManagedCefBrowserAdapter::InitializeBrowserProcessServiceHost
to catch the actual exception. We're not logging as it causes too many false positives as it's expected there will be errors
when browser is created then rapidly Disposed.

Resolves #2839
This commit is contained in:
amaitland
2019-07-27 21:49:49 +10:00
parent f35765fe3f
commit 5a3ce3c536
@@ -58,34 +58,46 @@ namespace CefSharp
{
auto channelFactory = browser->ChannelFactory;
try
//Add null check for issue https://github.com/cefsharp/CefSharp/issues/2839
if (channelFactory == nullptr)
{
if (channelFactory->State == CommunicationState::Opened)
LOG(ERROR) << "WcfEnabledSubProcess::OnBrowserDestroyed - browser->ChannelFactory was unexpectedly null, see https://github.com/cefsharp/CefSharp/issues/2839 for some debugging tips.";
}
else
{
try
{
channelFactory->Close();
if (channelFactory->State == CommunicationState::Opened)
{
channelFactory->Close();
}
}
catch (Exception^)
{
channelFactory->Abort();
}
}
catch (Exception^)
{
channelFactory->Abort();
}
auto clientChannel = ((IClientChannel^)browser->BrowserProcess);
try
//Add null check for issue https://github.com/cefsharp/CefSharp/issues/2839
if (browser->BrowserProcess != nullptr)
{
if (clientChannel->State == CommunicationState::Opened)
auto clientChannel = ((IClientChannel^)browser->BrowserProcess);
try
{
clientChannel->Close();
if (clientChannel->State == CommunicationState::Opened)
{
clientChannel->Close();
}
}
catch (Exception^)
{
clientChannel->Abort();
}
}
catch (Exception^)
{
clientChannel->Abort();
}
browser->ChannelFactory = nullptr;
browser->BrowserProcess = nullptr;
}
}
}
}