Bug 166284 - remove busy-timer in calc
Summary: remove busy-timer in calc
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.8.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Ahmed Elseyoufi
URL:
Whiteboard: target:26.8.0
Keywords: difficultyInteresting, easyHack, skillCpp, topicCleanup
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2025-04-21 17:17 UTC by Michael Meeks
Modified: 2026-03-23 21:13 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2025-04-21 17:17:16 UTC
Calc has (hopefully) after https://gerrit.libreoffice.org/c/core/+/184414 the last busy-timer which sits and spins for no really good reason - checking things we could have known about earlier.

sc/source/ui/app/scmod.cxx

IMPL_LINK_NOARG(ScModule, IdleHandler, Timer *, void)

Does several things that should happen at 'idle' - and possibly its fair enough to have a timeout instead of a very low priority idle: that's not clear - but ... we should not be doing this all the time with this complex back-off timeout.

if 'bMore' is not true - we should stop the timer not back-it off.

We should audit the things that are done here - so eg. if:

        // While calculating a Basic formula, a paint event may have occurred,
        // so check the bNeedsRepaint flags for this document's views

the bNeedsRepaint flag is set and was not set before - we should re-queue the calc timer to do this work - but otherwise not run it - we don't want to burn CPU and power un-necessarily if there is no basic formula in use eg. =)

similarly for links & calculating text width and so on - we should queue the idle handler as/when there is some real change it could do some work and not otherwise.

Patch linked above is a similar fix for swapping out objects.

Thanks ! =)
Comment 1 Ahmed Elseyoufi 2026-02-02 08:01:27 UTC
I'm working on this bug
Comment 2 Ahmed Elseyoufi 2026-02-09 19:25:51 UTC
I tried to solve this bug, but it kept failing on tests, So I need help

my approach is the following: 
   First of I update the AnyThingChanged() function to start the timer if it was      
   not active, and then in IdleHandler function if bMore is false then stop the 
   timer.

   second to start the timer again : 
       1. I looked for where bNeedsRepaint is set to true and I found it in two 
          files sc/source/ui/view/gridwin.cxx and sc/source/ui/view/gridwin4.cxx
          and after set the bNeedsRepaint I called AnyThingChanged().

       2. The same as TextWidth and I found it is been updated in 
          sc/source/core/data/table5.cxx which it was set to TEXTWIDTH_DIRTY,
          and I called AnyThingChanged() after it.

       3. For the links I found it is been updated on this file
          sc/source/core/tool/ddelink.cxx, in TryUpdate() function which was 
          was called from different locations when the links needs to be checked

This is what I did in this bug, but it failed on CppunitTest_chart2_import testTdf146756. And this what it says:

Test name: (anonymous namespace)::testTdf146756::TestBody
equality assertion failed
- Expected: 1697
- Actual  : 2013
- In <>, attribute 'sizeY' of '//XShape[@text='New service request and approval; 18%']' incorrect value.


And there were also a lot of warnings as well. 

How can I solve this issue?
Comment 3 Commit Notification 2026-03-06 20:59:26 UTC
seyoufi22 committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0d3563ad4e49cc767862fae0d79f632103111180

tdf#166284 stop idle timer completely when no work is pending

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Buovjaga 2026-03-08 11:14:54 UTC
Can this be closed as fixed?
Comment 5 Ahmed Elseyoufi 2026-03-09 20:08:16 UTC
(In reply to Buovjaga from comment #4)
> Can this be closed as fixed?

The main problem of the busy timer which it was spinning for no reason has been solved.
but I'm not sure if it still needs more work or not, maybe Caolan should confirm this.
Comment 6 Caolán McNamara 2026-03-23 21:13:55 UTC
yeah, I think we can