public static void Initialize(string pluginDirectory, string appDataDirectory, bool reportErrors) { if (!initialized) { if (reportErrors) { try { // Enable the Crashpad reporter. This *HAS* to happen before libcef.dll is loaded. EnableErrorReports(appDataDirectory); } catch (Exception) { // TODO: Log this exception. } } #if DEBUG var cefPath = Path.Combine(pluginDirectory, "libs", Environment.Is64BitProcess ? "x64" : "x86"); #else var cefPath = Path.Combine(appDataDirectory, "OverlayPluginCef", Environment.Is64BitProcess ? "x64" : "x86"); #endif var lang = System.Globalization.CultureInfo.CurrentCulture.Name; var langPak = Path.Combine(cefPath, "locales", lang + ".pak"); // Fall back to en-US if we can't find the current locale. if (!File.Exists(langPak)) { lang = "en-US"; } var cefSettings = new CefSettings { WindowlessRenderingEnabled = true, Locale = lang, CachePath = Path.Combine(appDataDirectory, "OverlayPluginCache"), MultiThreadedMessageLoop = true, LogFile = Path.Combine(appDataDirectory, "OverlayPluginCEF.log"), #if DEBUG LogSeverity = LogSeverity.Info, #else LogSeverity = LogSeverity.Error, #endif BrowserSubprocessPath = Path.Combine(cefPath, "CefSharp.BrowserSubprocess.exe"), }; try { File.WriteAllText(cefSettings.LogFile, ""); } catch (Exception) { // Ignore; if we can't open the log, CEF can't do it either which means that we don't have to worry about log size. } // Necessary to avoid input lag with a framerate limit below 60. cefSettings.CefCommandLineArgs["enable-begin-frame-scheduling"] = "1"; // Allow websites to play sound even if the user never interacted with that site (pretty common for our overlays) cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required"; // Disable Flash. We don't need it and it can cause issues. cefSettings.CefCommandLineArgs.Remove("enable-system-flash"); cefSettings.EnableAudio(); // Enables software compositing instead of GPU compositing -> less CPU load but no WebGL cefSettings.SetOffScreenRenderingBestPerformanceArgs(); Cef.Initialize(cefSettings, performDependencyCheck: true, browserProcessHandler: null); initialized = true; } }