Skip to content

Commit e274dd4

Browse files
committed
feat(ViewerView): Enable CEF error logging
Let's see if we can get some more insight into the problem some users experience.
1 parent 10073e5 commit e274dd4

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/SyncTrayzor/Pages/ViewerViewModel.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ private void SetCulture(Configuration configuration)
9191
{
9292
lock (cultureLock)
9393
{
94-
culture = configuration.UseComputerCulture ? CultureInfo.CurrentUICulture : CultureInfo.GetCultureInfoByIetfLanguageTag("en-US");
94+
culture = configuration.UseComputerCulture
95+
? CultureInfo.CurrentUICulture
96+
: CultureInfo.GetCultureInfoByIetfLanguageTag("en-US");
9597
}
9698
}
9799

@@ -107,13 +109,15 @@ protected override void OnInitialActivate()
107109
language = culture!.Name;
108110
}
109111

112+
var cefLogFile = pathsProvider.LogFilePath + @"\cef.log";
110113
var settings = new CefSettings()
111114
{
112115
RemoteDebuggingPort = AppSettings.Instance.CefRemoteDebuggingPort,
113116
// We really only want to set the LocalStorage path, but we don't have that level of control....
114117
CachePath = pathsProvider.CefCachePath,
118+
LogFile = cefLogFile,
115119
IgnoreCertificateErrors = true,
116-
LogSeverity = LogSeverity.Disable,
120+
LogSeverity = LogSeverity.Warning,
117121
AcceptLanguageList = language,
118122
Locale = language
119123
};
@@ -135,10 +139,23 @@ protected override void OnInitialActivate()
135139
{
136140
// CefSharp 139+ may set this by default, ignore if unable to set the flag.
137141
}
142+
138143
settings.CefCommandLineArgs.Add("disable-application-cache");
139144
}
140145

141-
Cef.Initialize(settings);
146+
try
147+
{
148+
if (!Cef.Initialize(settings))
149+
{
150+
throw new InvalidOperationException("Unable to initialize CEF.");
151+
}
152+
}
153+
catch (InvalidOperationException e)
154+
{
155+
throw new AggregateException(
156+
$"SyncTrayzor was unable to initialize its embedded browser.\nWhen reporting this issue, please attach the CEF logfile @ \n{cefLogFile}\n in addition to this message and the normal SyncTrayzor logfile.",
157+
e);
158+
}
142159
}
143160

144161
var webBrowser = new ChromiumWebBrowser();

0 commit comments

Comments
 (0)