<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Ongoing 100% CPU usage after opening document"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=141556#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Ongoing 100% CPU usage after opening document"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=141556">bug 141556</a>
              from <span class="vcard"><a class="email" href="mailto:luke@deller.id.au" title="Luke Deller <luke@deller.id.au>"> <span class="fn">Luke Deller</span></a>
</span></b>
        <pre>I believe what is happening here is the idle layout processing keeps getting
interrupted on page 15.  Each time it is invoked, it resumes from page 15 but
does not progress far enough before being interrupted again, so next time it
resumes back at the same point - so it never finishes.

There was a stopwatch timer introduced in commit
383032c50a3e3354f04200ce984a47ab9d2c5c67 for <a class="bz_bug_link 
          bz_status_VERIFIED  bz_closed"
   title="VERIFIED FIXED - Processing loop for SfxEnumItem<enum SwFootnoteEndPosEnum>"
   href="show_bug.cgi?id=123583">tdf#123583</a>, which interrupts idle
processing every 50 milliseconds.  To test my explanation of the problem, I
tried extending this timer to 60 seconds, and that does indeed fix the problem
- but this is not the right fix because the application is unresponsive for too
long when the document is opened because the idle task is not being interrupted
at all.

Instead I tried reverting commit 383032c50a3e3354f04200ce984a47ab9d2c5c67,
which brings us back to the previous behaviour where idle processing is only
interrupted if there is some input event.  In theory this sounds great, but I
saw that the idle processing was still being interrupted many times per second
causing the same symptoms.  Debugging with gdb, I saw this was a TIMER event.

This is very similar to problems addressed previously in commit
b4f35a7450830979b937ec6ae3b6d638302093d2 (2015) and commit
6160127ba9b03b991736e0157c2d134795fa196f (2005), which filter out TIMER events
so that they will not interrupt idle processing - but these commits missed one
spot!  This line:
<a href="https://git.libreoffice.org/core/+/refs/changes/90/18590/2/sw/source/core/layout/layact.cxx/#2168">https://git.libreoffice.org/core/+/refs/changes/90/18590/2/sw/source/core/layout/layact.cxx/#2168</a>

When I apply a similar change onto this line, the present bug is fixed for me:
CPU usage is high for about 12 seconds then drops to zero.  Also this
(re-)fixes <a class="bz_bug_link 
          bz_status_VERIFIED  bz_closed"
   title="VERIFIED FIXED - Processing loop for SfxEnumItem<enum SwFootnoteEndPosEnum>"
   href="show_bug.cgi?id=123583">tdf#123583</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>