From db18d188b84b5c4d2af72b26426431470b495813 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 21 Jan 2016 14:46:45 -0800 Subject: [PATCH] Fix wifi ping spikes Moves the setting of Qt's bearer poll timeout earlier to be sure it's caught. --- assignment-client/src/AssignmentClientApp.cpp | 4 ---- assignment-client/src/main.cpp | 8 ++++++-- domain-server/src/DomainServer.cpp | 4 ---- domain-server/src/main.cpp | 2 ++ interface/src/Application.cpp | 3 --- interface/src/main.cpp | 3 ++- libraries/shared/src/SharedUtil.cpp | 6 ++++++ libraries/shared/src/SharedUtil.h | 2 ++ 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index 8a36d99c75..3a962d72d2 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -29,10 +29,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { - // to work around the Qt constant wireless scanning, set the env for polling interval very high - const QByteArray EXTREME_BEARER_POLL_TIMEOUT = QString::number(INT_MAX).toLocal8Bit(); - qputenv("QT_BEARER_POLL_TIMEOUT", EXTREME_BEARER_POLL_TIMEOUT); - # ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); # endif diff --git a/assignment-client/src/main.cpp b/assignment-client/src/main.cpp index 5d08848b8b..052c4755f8 100644 --- a/assignment-client/src/main.cpp +++ b/assignment-client/src/main.cpp @@ -9,11 +9,15 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "AssignmentClientApp.h" - #include +#include + +#include "AssignmentClientApp.h" + int main(int argc, char* argv[]) { + disableQtBearerPoll(); // Fixes wifi ping spikes + AssignmentClientApp app(argc, argv); int acReturn = app.exec(); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 6d49b39d10..541ee3ba16 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -65,10 +65,6 @@ DomainServer::DomainServer(int argc, char* argv[]) : LogUtils::init(); Setting::init(); - - // to work around the Qt constant wireless scanning, set the env for polling interval very high - const QByteArray EXTREME_BEARER_POLL_TIMEOUT = QString::number(INT_MAX).toLocal8Bit(); - qputenv("QT_BEARER_POLL_TIMEOUT", EXTREME_BEARER_POLL_TIMEOUT); connect(this, &QCoreApplication::aboutToQuit, this, &DomainServer::aboutToQuit); diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 790cc07c56..b3b5c8b9be 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -23,6 +23,8 @@ #include "DomainServer.h" int main(int argc, char* argv[]) { + disableQtBearerPoll(); // Fixes wifi ping spikes + #ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); #endif diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a6d396400e..d9e8d67bca 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -422,9 +422,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : auto controllerScriptingInterface = DependencyManager::get().data(); _controllerScriptingInterface = dynamic_cast(controllerScriptingInterface); - // to work around the Qt constant wireless scanning, set the env for polling interval very high - const QByteArray EXTREME_BEARER_POLL_TIMEOUT = QString::number(INT_MAX).toLocal8Bit(); - qputenv("QT_BEARER_POLL_TIMEOUT", EXTREME_BEARER_POLL_TIMEOUT); _entityClipboard->createRootElement(); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 89511a4d9b..15da88023b 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -25,6 +25,8 @@ #include "MainWindow.h" int main(int argc, const char* argv[]) { + disableQtBearerPoll(); // Fixes wifi ping spikes + QString applicationName = "High Fidelity Interface - " + qgetenv("USERNAME"); bool instanceMightBeRunning = true; @@ -81,7 +83,6 @@ int main(int argc, const char* argv[]) { #endif } - QElapsedTimer startupTime; startupTime.start(); diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 298d5f669b..4c893e7074 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -685,3 +685,9 @@ bool similarStrings(const QString& stringA, const QString& stringB) { return similarity >= SIMILAR_ENOUGH; } +void disableQtBearerPoll() { + // to work around the Qt constant wireless scanning, set the env for polling interval very high + const QByteArray EXTREME_BEARER_POLL_TIMEOUT = QString::number(INT_MAX).toLocal8Bit(); + qputenv("QT_BEARER_POLL_TIMEOUT", EXTREME_BEARER_POLL_TIMEOUT); +} + diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 89ccba1479..1fae3bcff6 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -172,4 +172,6 @@ uint qHash(const std::shared_ptr& ptr, uint seed = 0) return qHash(ptr.get(), seed); } +void disableQtBearerPoll(); + #endif // hifi_SharedUtil_h