summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-20 14:16:08 -0400
committerAshod Nakashian <ashnakash@gmail.com>2018-12-03 08:10:32 +0100
commit349748e63c698076bb44f75da9eaa104489e959c (patch)
tree4db4935e5606bed6ccf3557f78e4a3a10f552e71
parent644188bf7f3a07222f2b58a3794348197fb8ad24 (diff)
sw lok: delay processing idle jobs to let LOK finish initialization
When loading document, LOK needs to setup the client view, register callbacks, get document size and type, etc. All of these need to take SolarMutex, which is taken by the idle jobs immediately after loading, blocking LOK from finishing initialization and rendering the first tiles for the user. This gives the user the impression that the document is loading for far longer than it actually is, due to lack of interactivity (or indeed any activity on the screen besides the spinning wheel). By delaying the idle jobs, we allow time for LOK to finish initialization and render the first tiles before the idle jobs kick in and hog SolarMutex. Reviewed-on: https://gerrit.libreoffice.org/56572 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 1056640a6e1fd044cb61f5bf5ee85dfec3cbeb7c) Reviewed-on: https://gerrit.libreoffice.org/58157 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit e5225f152c3128efa73cb602d7a524f2cb436189) Change-Id: Ic6f437bfd6f43dfed2aaa1a9d3510d43f5ec30ae Reviewed-on: https://gerrit.libreoffice.org/64013 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sw/source/core/doc/DocumentTimerManager.cxx34
-rw-r--r--sw/source/core/inc/DocumentTimerManager.hxx7
2 files changed, 35 insertions, 6 deletions
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 44984c86e583..e80c74c695eb 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -34,22 +34,38 @@
#include <docfld.hxx>
#include <fldbas.hxx>
#include <vcl/scheduler.hxx>
+#include <comphelper/lok.hxx>
namespace sw
{
-
-DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
- m_nIdleBlockCount( 0 ),
- m_bStartOnUnblock( false ),
- m_aDocIdle( i_rSwdoc )
+DocumentTimerManager::DocumentTimerManager(SwDoc& i_rSwdoc)
+ : m_rDoc(i_rSwdoc)
+ , m_nIdleBlockCount(0)
+ , m_bStartOnUnblock(false)
+ , m_aDocIdle(i_rSwdoc)
+ , m_aFireIdleJobsTimer("sw::DocumentTimerManager m_aFireIdleJobsTimer")
+ , m_bWaitForLokInit(true)
{
m_aDocIdle.SetPriority(TaskPriority::LOWEST);
- m_aDocIdle.SetInvokeHandler(LINK( this, DocumentTimerManager, DoIdleJobs));
+ m_aDocIdle.SetInvokeHandler(LINK(this, DocumentTimerManager, DoIdleJobs));
m_aDocIdle.SetDebugName("sw::DocumentTimerManager m_aDocIdle");
+
+ m_aFireIdleJobsTimer.SetInvokeHandler(LINK(this, DocumentTimerManager, FireIdleJobsTimeout));
+ m_aFireIdleJobsTimer.SetTimeout(1000); // Enough time for LOK to render the first tiles.
}
void DocumentTimerManager::StartIdling()
{
+ if (m_bWaitForLokInit && comphelper::LibreOfficeKit::isActive())
+ {
+ // Start the idle jobs only after a certain delay.
+ m_bWaitForLokInit = false;
+ StopIdling();
+ m_aFireIdleJobsTimer.Start();
+ return;
+ }
+
+ m_bWaitForLokInit = false;
m_bStartOnUnblock = true;
if (0 == m_nIdleBlockCount)
{
@@ -86,6 +102,12 @@ void DocumentTimerManager::UnblockIdling()
}
}
+IMPL_LINK(DocumentTimerManager, FireIdleJobsTimeout, Timer*, , void)
+{
+ // Now we can run the idle jobs, assuming we finished LOK initialization.
+ StartIdling();
+}
+
DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
{
SwRootFrame* pTmpRoot = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx
index 2caaf608c40d..df0a5d2b1ce6 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -23,6 +23,7 @@
#include <IDocumentTimerAccess.hxx>
#include <SwDocIdle.hxx>
+#include <vcl/idle.hxx>
#include <sal/types.h>
#include <tools/link.hxx>
@@ -60,6 +61,10 @@ private:
DocumentTimerManager(DocumentTimerManager const&) = delete;
DocumentTimerManager& operator=(DocumentTimerManager const&) = delete;
+ /// Delay starting idle jobs to allow for post-load activity.
+ /// Used by LOK only.
+ DECL_LINK( FireIdleJobsTimeout, Timer *, void );
+
DECL_LINK( DoIdleJobs, Timer *, void );
IdleJob GetNextIdleJob() const;
@@ -69,6 +74,8 @@ private:
sal_uInt32 m_nIdleBlockCount; ///< Don't run the Idle, if > 0
bool m_bStartOnUnblock; ///< true, if the last unblock should start the timer
SwDocIdle m_aDocIdle;
+ Timer m_aFireIdleJobsTimer;
+ bool m_bWaitForLokInit; ///< true if we waited for LOK to initialize already.
};
inline bool DocumentTimerManager::IsDocIdle() const