summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-24 00:11:04 +0200
committerMichael Meeks <michael.meeks@collabora.com>2021-10-05 20:19:32 +0200
commit24ad72393a26a0d6f2a0f2d79acc51fc28533234 (patch)
tree5fa78094cb4ca1b869fafbf11820f8448bf0b849
parent9688743c56d2befe96fa799eea16b4a00e0419e1 (diff)
add extra timeout with higher priority to LOK flushing
The normal idle has TaskPriority::POST_PAINT, which means that if we get too busy, the idle won't be called for a long time, meaning the queue will get longer and longer, making its processing slower, and client interactivity will be very poor, with updates possibly coming only when everything becomes idle. The second timeout will flush the queue after a reasonable timeout. I don't think there's an optimal value, so let's choose 100ms for now. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122737 Tested-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 3f6f1a45c1f4225817188f97721e6546e38871e2) Change-Id: Ia1312a690aefd2c8628c82e0f42b2993802d8b1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122943 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--desktop/inc/lib/init.hxx9
-rw-r--r--desktop/source/lib/init.cxx23
2 files changed, 30 insertions, 2 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 580a8e47d9a5..ef8494ed7b0d 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -144,6 +144,15 @@ namespace desktop {
int m_nDisableCallbacks;
bool m_bEventLatch;
std::mutex m_mutex;
+ class TimeoutIdle : public Timer
+ {
+ public:
+ TimeoutIdle( CallbackFlushHandler* handler );
+ virtual void Invoke() override;
+ private:
+ CallbackFlushHandler* mHandler;
+ };
+ TimeoutIdle m_TimeoutIdle;
};
struct DESKTOP_DLLPUBLIC LibLODocument_Impl : public _LibreOfficeKitDocument
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 71098de551cb..9edc10d013e4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1405,13 +1405,29 @@ static OUString getGenerator()
extern "C" {
+CallbackFlushHandler::TimeoutIdle::TimeoutIdle( CallbackFlushHandler* handler )
+ : Timer( "lokit timer callback" )
+ , mHandler( handler )
+{
+ // A second timer with higher priority, it'll ensure we flush in reasonable time if we get too busy
+ // to get POST_PAINT priority processing. Otherwise it could take a long time to flush.
+ SetPriority(TaskPriority::DEFAULT);
+ SetTimeout( 100 ); // 100 ms
+}
+
+void CallbackFlushHandler::TimeoutIdle::Invoke()
+{
+ mHandler->Invoke();
+}
+
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData)
- : Idle( "lokit timer callback" ),
+ : Idle( "lokit idle callback" ),
m_pDocument(pDocument),
m_pCallback(pCallback),
m_pData(pData),
m_nDisableCallbacks(0),
- m_bEventLatch(false)
+ m_bEventLatch(false),
+ m_TimeoutIdle( this )
{
SetPriority(TaskPriority::POST_PAINT);
@@ -1708,6 +1724,8 @@ void CallbackFlushHandler::queue(const int type, const char* data)
{
Start();
}
+ if (!m_TimeoutIdle.IsActive())
+ m_TimeoutIdle.Start();
}
bool CallbackFlushHandler::processInvalidateTilesEvent(int type, CallbackData& aCallbackData)
@@ -2094,6 +2112,7 @@ void CallbackFlushHandler::Invoke()
m_queue1.clear();
m_queue2.clear();
+ m_TimeoutIdle.Stop();
}
}