[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 26 02:37:27 UTC 2019
sw/source/core/doc/DocumentTimerManager.cxx | 34 +++++++++++++++++++++++-----
sw/source/core/inc/DocumentTimerManager.hxx | 7 +++++
2 files changed, 35 insertions(+), 6 deletions(-)
New commits:
commit c058e9518cdc4531737a47148fe49e4044d73d74
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Oct 20 14:16:08 2018 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Thu Dec 26 03:36:54 2019 +0100
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 at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
(cherry picked from commit 1056640a6e1fd044cb61f5bf5ee85dfec3cbeb7c)
Reviewed-on: https://gerrit.libreoffice.org/58157
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at 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 at gmail.com>
(cherry picked from commit 349748e63c698076bb44f75da9eaa104489e959c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85798
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 5d8c425dfd46..d290e70942b8 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
More information about the Libreoffice-commits
mailing list