From a66e872e4e774be3f1e4593ad8c928a149a48dba Mon Sep 17 00:00:00 2001 From: Stefan Seibert Date: Wed, 4 Dec 2019 10:01:35 +0100 Subject: [PATCH] Improvements in Performance due to adopted usage of CEF Message Loop (#1017) * Changing the way how we pump the CEF update loop to improve performance * Updated Intervall description --- modules/webbrowser/src/webbrowserapp.cpp | 5 +++-- modules/webbrowser/webbrowsermodule.cpp | 20 +++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/webbrowser/src/webbrowserapp.cpp b/modules/webbrowser/src/webbrowserapp.cpp index dc49bd8fa9..f5f1aa05ac 100644 --- a/modules/webbrowser/src/webbrowserapp.cpp +++ b/modules/webbrowser/src/webbrowserapp.cpp @@ -43,8 +43,9 @@ void WebBrowserApp::OnContextCreated(CefRefPtr, CefRefPtr, void WebBrowserApp::OnBeforeCommandLineProcessing(const CefString&, CefRefPtr commandLine) { -// command_line->AppendSwitch("disable-gpu"); -// command_line->AppendSwitch("disable-gpu-compositing"); + commandLine->AppendSwitch("disable-gpu"); + commandLine->AppendSwitch("disable-gpu-compositing"); + commandLine->AppendSwitch("enable-begin-frame-scheduling"); commandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required"); } diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index bf11e5eb34..eb86fe070b 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -142,16 +142,6 @@ void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) { _cefHost = std::make_unique(_webHelperLocation); LDEBUG("Starting CEF... done!"); - global::callback::preSync.emplace_back([this]() { - if (_cefHost && !_browsers.empty()) { - _cefHost->doMessageLoopWork(); - - const std::chrono::time_point timeAfter = - std::chrono::high_resolution_clock::now(); - webbrowser::latestCall = timeAfter; - } - }); - if (dictionary.hasValue(UpdateBrowserBetweenRenderablesInfo.identifier)) { _updateBrowserBetweenRenderables = dictionary.value(UpdateBrowserBetweenRenderablesInfo.identifier); @@ -218,14 +208,18 @@ bool WebBrowserModule::isEnabled() const { return _enabled; } -namespace webbrowser { - /** * Logic for the webbrowser performance hotfix, * described in more detail in globalscallbacks.h. */ +namespace webbrowser { -std::chrono::microseconds interval = std::chrono::microseconds(1); + /** +* The time interval to describe how often the CEF message loop needs to +* be pumped to work properly. A value of 10000 us updates CEF a 100 times +* per second which is enough for fluid interaction without wasting resources +*/ +std::chrono::microseconds interval = std::chrono::microseconds(10000); std::chrono::time_point latestCall; CefHost* cefHost = nullptr;