From cfbcc4093c70cbc52a7f029b14e30f17f2586962 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 9 Sep 2018 10:17:32 -0700 Subject: [PATCH] Reduce UI jank when transitioning to the stream segue --- app/streaming/session.cpp | 14 ++++++++++++-- app/streaming/session.hpp | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 9cd9e17e..3cb77dd6 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -278,6 +278,11 @@ Session::Session(NvComputer* computer, NvApp& app) m_DisplayOriginX(0), m_DisplayOriginY(0), m_PendingWindowedTransition(false) +{ + +} + +void Session::initialize() { qDebug() << "Server GPU:" << m_Computer->gpuModel; @@ -366,14 +371,14 @@ Session::Session(NvComputer* computer, NvApp& app) break; } - if (computer->activeAddress == computer->remoteAddress) { + if (m_Computer->activeAddress == m_Computer->remoteAddress) { m_StreamConfig.streamingRemotely = 1; } else { m_StreamConfig.streamingRemotely = 0; } - if (computer->activeAddress == computer->localAddress) { + if (m_Computer->activeAddress == m_Computer->localAddress) { m_StreamConfig.packetSize = 1392; } else { @@ -701,6 +706,11 @@ void Session::exec(int displayOriginX, int displayOriginY) m_DisplayOriginX = displayOriginX; m_DisplayOriginY = displayOriginY; + // Complete initialization in this deferred context to avoid + // calling expensive functions in the constructor (during the + // process of loading the StreamSegue). + initialize(); + // Check for validation errors/warnings and emit // signals for them, if appropriate if (!validateLaunch()) { diff --git a/app/streaming/session.hpp b/app/streaming/session.hpp index 4e9ccbc9..24d261e5 100644 --- a/app/streaming/session.hpp +++ b/app/streaming/session.hpp @@ -41,6 +41,8 @@ signals: void displayLaunchWarning(QString text); private: + void initialize(); + bool validateLaunch(); void emitLaunchWarning(QString text);