diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-06-28 01:02:49 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-09-12 18:02:55 +0200 |
commit | e5225f152c3128efa73cb602d7a524f2cb436189 (patch) | |
tree | f05c5e0fd6b6256cf8fb46c582c0bd93e9280ca6 /sw/source | |
parent | 0c9924495eb8010eedd3c93641f995ae560b3aad (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)
Change-Id: Ic6f437bfd6f43dfed2aaa1a9d3510d43f5ec30ae
Reviewed-on: https://gerrit.libreoffice.org/58157
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/DocumentTimerManager.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentTimerManager.hxx | 6 |
2 files changed, 29 insertions, 3 deletions
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx index 5429c6edbda6..4afab01a64d3 100644 --- a/sw/source/core/doc/DocumentTimerManager.cxx +++ b/sw/source/core/doc/DocumentTimerManager.cxx @@ -33,6 +33,7 @@ #include <docsh.hxx> #include <docfld.hxx> #include <fldbas.hxx> +#include <comphelper/lok.hxx> namespace sw { @@ -45,6 +46,10 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc maDocIdle.SetPriority( TaskPriority::LOWEST ); maDocIdle.SetInvokeHandler( LINK( this, DocumentTimerManager, DoIdleJobs) ); maDocIdle.SetDebugName( "sw::DocumentTimerManager maDocIdle" ); + + maFireIdleJobsTimer.SetInvokeHandler(LINK(this, DocumentTimerManager, FireIdleJobsTimeout)); + maFireIdleJobsTimer.SetTimeout(1000); // Enough time for LOK to render the first tiles. + maFireIdleJobsTimer.SetDebugName("sw::DocumentTimerManager maFireIdleJobsTimer"); } void DocumentTimerManager::StartIdling() @@ -75,9 +80,24 @@ void DocumentTimerManager::UnblockIdling() void DocumentTimerManager::StartBackgroundJobs() { - // Trigger DoIdleJobs(), asynchronously. - if (!maDocIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0 - maDocIdle.Start(); + if (comphelper::LibreOfficeKit::isActive()) + { + /// Reset the timer to fire after the last StartBackgroundJobs. + maFireIdleJobsTimer.Start(); + StopIdling(); + } + else + { + // Trigger DoIdleJobs(), asynchronously. + if (!maDocIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0 + maDocIdle.Start(); + } +} + +IMPL_LINK( DocumentTimerManager, FireIdleJobsTimeout, Timer *, pTimer, void ) +{ + (void)pTimer; + StartIdling(); } DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const diff --git a/sw/source/core/inc/DocumentTimerManager.hxx b/sw/source/core/inc/DocumentTimerManager.hxx index d8c1a76b2a14..c2e923dc6543 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> @@ -56,6 +57,10 @@ public: void StartBackgroundJobs() override; + /// Delay starting idle jobs to allow for post-load activity. + /// Used by LOK only. + DECL_LINK( FireIdleJobsTimeout, Timer *, void ); + bool IsDocIdle() const override; private: @@ -71,6 +76,7 @@ private: bool mbStartIdleTimer; //< idle timer mode start/stop sal_Int32 mIdleBlockCount; SwDocIdle maDocIdle; + Timer maFireIdleJobsTimer; }; inline bool DocumentTimerManager::IsDocIdle() const |