Skip to content

Commit

Permalink
WcfEnabledSubProcess - OnBrowserDestroyed add null checks and log msg…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
amaitland committed Jul 27, 2019
1 parent 6cc1026 commit 6c7d15d
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions CefSharp.BrowserSubprocess.Core/WcfEnabledSubProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
channelFactory->Close();
}
LOG(ERROR) << "WcfEnabledSubProcess::OnBrowserDestroyed - browser->ChannelFactory was unexpectedly null, see https://github.com/cefsharp/CefSharp/issues/2839 for some debugging tips.";
}
catch (Exception^)
else
{
channelFactory->Abort();
try
{
if (channelFactory->State == CommunicationState::Opened)
{
channelFactory->Close();
}
}
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;
}
}
}
}

0 comments on commit 6c7d15d

Please sign in to comment.