Skip to content

Commit 5a3ce3c

Browse files
committed
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
1 parent f35765f commit 5a3ce3c

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

CefSharp.BrowserSubprocess.Core/WcfEnabledSubProcess.cpp

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,46 @@ namespace CefSharp
5858
{
5959
auto channelFactory = browser->ChannelFactory;
6060

61-
try
61+
//Add null check for issue https://github.com/cefsharp/CefSharp/issues/2839
62+
if (channelFactory == nullptr)
6263
{
63-
if (channelFactory->State == CommunicationState::Opened)
64-
{
65-
channelFactory->Close();
66-
}
64+
LOG(ERROR) << "WcfEnabledSubProcess::OnBrowserDestroyed - browser->ChannelFactory was unexpectedly null, see https://github.com/cefsharp/CefSharp/issues/2839 for some debugging tips.";
6765
}
68-
catch (Exception^)
66+
else
6967
{
70-
channelFactory->Abort();
68+
try
69+
{
70+
if (channelFactory->State == CommunicationState::Opened)
71+
{
72+
channelFactory->Close();
73+
}
74+
}
75+
catch (Exception^)
76+
{
77+
channelFactory->Abort();
78+
}
7179
}
7280

73-
auto clientChannel = ((IClientChannel^)browser->BrowserProcess);
74-
75-
try
81+
//Add null check for issue https://github.com/cefsharp/CefSharp/issues/2839
82+
if (browser->BrowserProcess != nullptr)
7683
{
77-
if (clientChannel->State == CommunicationState::Opened)
84+
auto clientChannel = ((IClientChannel^)browser->BrowserProcess);
85+
86+
try
7887
{
79-
clientChannel->Close();
88+
if (clientChannel->State == CommunicationState::Opened)
89+
{
90+
clientChannel->Close();
91+
}
92+
}
93+
catch (Exception^)
94+
{
95+
clientChannel->Abort();
8096
}
81-
}
82-
catch (Exception^)
83-
{
84-
clientChannel->Abort();
8597
}
8698

8799
browser->ChannelFactory = nullptr;
88100
browser->BrowserProcess = nullptr;
89101
}
90102
}
91-
}
103+
}

0 commit comments

Comments
 (0)