sfx2/source/control/bindings.cxx                |    3 --
 sw/qa/extras/tiledrendering/tiledrendering2.cxx |   27 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit b71b0c7d18e6a5e52272e5305f4b3d9fc06e3897
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Sep 23 08:33:07 2025 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Sep 23 09:22:40 2025 +0200

    cool#12964 sfx2: fix priority of 'sfx::SfxBindings aAutoTimer'
    
    Open the bugdoc in a LOK client, go to page 2, press backspace twice,
    the expected result is that we get tiles fast, but actually we have a
    delay on the 2nd backspace.
    
    Investigating what happens, simply the LOK client is informed that a
    high priority VCL task is scheduled, so the tiles are not rendered:
    debug:589:484: SwEditWin::KeyInput: start
    ...
    debug:589:484: SwEditWin::KeyInput: finished in 18 ms
    ...
    debug, anyInputCallback: no input, return false
    debug:589:484: SwLayAction::CheckIdleEnd: after LOK anyInput(), 
m_bInterrupt is 0
    debug:589:484: Scheduler::GetMostUrgentTaskPriority: reporting 2 as the 
most urgent priority, task is 'sfx::SfxBindings aAutoTimer' @ 1902333277
    debug, anyInputCallback: mostUrgentPriority is highest..repaint, no 
interrupt, return false
    ...
    debug:589:484: Scheduler::GetMostUrgentTaskPriority: reporting 2 as the 
most urgent priority, task is 'sfx::SfxBindings aAutoTimer' @ 1902333976 -> 699 
ms here
    debug, anyInputCallback: mostUrgentPriority is highest..repaint, no 
interrupt, return false
    debug:589:484: SwLayAction::CheckIdleEnd: after LOK anyInput(), 
m_bInterrupt is 0
    debug:589:484: SwLayAction::Action: is idle? 1, 1st InternalAction() 
finished in 976 ms
    ...
    debug:589:484: SwEditWin::KeyInput: start
    debug:589:484: SwEditWin::KeyInput: finished in 1 ms
    
    Fix the problem by restoring the priority of 'sfx::SfxBindings
    aAutoTimer' to the value that was set by commit
    4f15a47c7faf55997e776af738106d3da229c7d2 (cool#11064 Set priority of
    some idles to TaskPriority::DEFAULT_IDLE, 2025-02-18), but in the
    meantime the pulled-from-upstream commit
    f4ade8244bf984712e65c2eb82cf3319d2679eeb (Downgrade sfx::SfxBindings
    aAutoTimer to an idle, 2024-03-21) broke the priority again.
    
    With this, we stop idle layout as soon as the 2nd keypress arrives:
    debug:5279:5148: SwEditWin::KeyInput: start
    debug:5279:5148: SwEditWin::KeyInput: finished in 6 ms
    ...
    debug:5279:5148: Scheduler::GetMostUrgentTaskPriority: reporting 7 as the 
most urgent priority, task is 'sfx::SfxBindings aAutoTimer' @ 1903486975
    debug, anyInputCallback: no input, return false
    debug:5279:5148: SwLayAction::CheckIdleEnd: after LOK anyInput(), 
m_bInterrupt is 0
    debug, anyInputCallback: wsd socket poll() found data, return true
    debug:5279:5148: SwLayAction::CheckIdleEnd: after LOK anyInput(), 
m_bInterrupt is 1
    debug:5279:5148: SwLayAction::Action: is idle? 1, 1st InternalAction() 
finished in 488 ms
    debug:5279:5148: SwLayAction::Action: is idle? 0, 1st InternalAction() 
finished in 0 ms
    debug:5279:5148: Scheduler::GetMostUrgentTaskPriority: reporting 4 as the 
most urgent priority, task is 'vcl::Window maPaintIdle' @ 1903486976
    debug, anyInputCallback: mostUrgentPriority is highest..repaint, no 
interrupt, return false
    debug:5279:5148: Scheduler::GetMostUrgentTaskPriority: reporting 7 as the 
most urgent priority, task is 'sfx::SfxBindings aAutoTimer' @ 1903486976
    debug, anyInputCallback: unprocessed LOK callbacks, return true
    debug:5279:5148: SwEditWin::KeyInput: start
    debug:5279:5148: SwEditWin::KeyInput: finished in 1 ms
    
    Change-Id: I80caee230d8d3ae66dd04133e3101721443860f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191376
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 744a3dc1a7b4..550604cf0862 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -146,10 +146,9 @@ SfxBindings::SfxBindings()
     pImpl->pSubBindings = nullptr;
     pImpl->nOwnRegLevel = nRegLevel;
 
-    pImpl->aAutoTimer.SetPriority(TaskPriority::DEFAULT_IDLE);
     // all caches are valid (no pending invalidate-job)
     // create the list of caches
-    pImpl->aAutoTimer.SetPriority(TaskPriority::HIGH_IDLE);
+    pImpl->aAutoTimer.SetPriority(TaskPriority::DEFAULT_IDLE);
     pImpl->aAutoTimer.SetInvokeHandler( LINK(this, SfxBindings, NextJob) );
 }
 
diff --git a/sw/qa/extras/tiledrendering/tiledrendering2.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering2.cxx
index 324f53389845..9d93fc0603ee 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering2.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering2.cxx
@@ -807,6 +807,33 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testIdleLayoutShape)
     // i.e. the priority was TaskPriority::REPAINT instead of 
TaskPriority::DEFAULT_IDLE.
     CPPUNIT_ASSERT_GREATER(TaskPriority::REPAINT, rDrawIdle.GetPriority());
 }
+
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testIdleLayoutPageDelete)
+{
+    // Given a document with 2 pages, cursor is after the page break:
+    createSwDoc();
+    SwDocShell* pDocShell = getSwDocShell();
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    pWrtShell->Insert(u"x"_ustr);
+    pWrtShell->InsertPageBreak();
+    SwRootFrame* pLayout = pWrtShell->GetLayout();
+    sal_uInt16 nLastPage = pLayout->GetLastPage()->GetPhyPageNum();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(2), nLastPage);
+
+    // When deleting the page break, mutating the page count:
+    pWrtShell->DelLeft();
+
+    // Then make sure the bindings (status bar, etc) is updated with an idle 
VCL task:
+    nLastPage = pLayout->GetLastPage()->GetPhyPageNum();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), nLastPage);
+    SfxViewFrame& rFrame = pWrtShell->GetView().GetViewFrame();
+    Timer& rBindingsTimer = rFrame.GetBindings().GetTimer();
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected greater than: 4
+    // - Actual  : 2
+    // i.e. the priority was TaskPriority::HIGH_IDLE instead of 
TaskPriority::DEFAULT_IDLE.
+    CPPUNIT_ASSERT_GREATER(TaskPriority::REPAINT, 
rBindingsTimer.GetPriority());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to