Kaydet (Commit) 349748e6 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

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/56572Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
(cherry picked from commit 1056640a)

Reviewed-on: https://gerrit.libreoffice.org/58157Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
(cherry picked from commit e5225f15)

Change-Id: Ic6f437bfd6f43dfed2aaa1a9d3510d43f5ec30ae
Reviewed-on: https://gerrit.libreoffice.org/64013
Tested-by: Jenkins
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 644188bf
......@@ -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();
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment