Kaydet (Commit) 1056640a authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Jan Holesovsky

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.

Change-Id: Ic6f437bfd6f43dfed2aaa1a9d3510d43f5ec30ae
Reviewed-on: https://gerrit.libreoffice.org/56572Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst e7f65920
......@@ -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
maIdle.SetPriority( SchedulerPriority::LOWEST );
maIdle.SetIdleHdl( LINK( this, DocumentTimerManager, DoIdleJobs) );
maIdle.SetDebugName( "sw::DocumentTimerManager maIdle" );
maFireIdleJobsTimer.SetTimeoutHdl(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 (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
maIdle.Start();
if (comphelper::LibreOfficeKit::isActive())
{
/// Reset the timer to fire after the last StartBackgroundJobs.
maFireIdleJobsTimer.Start();
StopIdling();
}
else
{
// Trigger DoIdleJobs(), asynchronously.
if (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
maIdle.Start();
}
}
IMPL_LINK( DocumentTimerManager, FireIdleJobsTimeout, Timer *, pTimer, void )
{
(void)pTimer;
StartIdling();
}
IMPL_LINK( DocumentTimerManager, DoIdleJobs, Idle*, pIdle, void )
......
......@@ -23,6 +23,7 @@
#include <IDocumentTimerAccess.hxx>
#include <vcl/idle.hxx>
#include <vcl/timer.hxx>
#include <sal/types.h>
#include <tools/link.hxx>
......@@ -50,6 +51,10 @@ public:
// Our own 'IdleTimer' calls the following method
DECL_LINK( DoIdleJobs, Idle *, void );
/// Delay starting idle jobs to allow for post-load activity.
/// Used by LOK only.
DECL_LINK( FireIdleJobsTimeout, Timer *, void );
virtual ~DocumentTimerManager() override;
private:
......@@ -62,6 +67,7 @@ private:
bool mbStartIdleTimer; //< idle timer mode start/stop
sal_Int32 mIdleBlockCount;
Idle maIdle;
Timer maFireIdleJobsTimer;
};
}
......
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