Bug 92036 - Writer infinite idle spelling loop ...
Summary: Writer infinite idle spelling loop ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.0.0.0.beta1
Hardware: Other All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:5.1.0 target:5.0.0.1 target:5...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-12 15:58 UTC by Michael Meeks
Modified: 2022-10-21 18:31 UTC (History)
7 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 2015-06-12 15:58:00 UTC
This bug is verified in 4.3 eg. just break in

#0  SwTxtFrm::_AutoSpell (this=this@entry=0x7fffd8066000, pActNode=<optimized out>, rViewOpt=..., nActPos=8) at /data/opt/libreoffice/cp-4.3/sw/source/core/txtnode/txtedt.cxx:1388

and type: "testtest" into writer ... but it happens much less frequently since the spell-checking timeout is much slower.

Essentially it seems we (incorrectly?) fail to mark the relevant node's "wrongdirty" flag - as we set it wrong:

        pNode->SetWrongDirty( COMPLETE_STRING != pNode->GetWrong()->GetBeginInv() );

So we get this idle handler continuously called.

The slight down-side of this is that since we fixed the idle stack to actually execute idle handlers at top tilt - this now consumes 100% CPU time (not making progress) - and also blocks incoming UNO callers.
Comment 1 Commit Notification 2015-06-13 08:09:45 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f645f21eb7c1fbf4addaeff19c1c3dd9c553431c

tdf#92036 - work around writer spelling issue

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 2 Commit Notification 2015-06-15 16:21:29 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a0faaf32381d30ca9dd834511271b7f45299c74c&h=libreoffice-5-0

tdf#92036 - work around writer spelling issue

It will be available in 5.0.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Ashod Nakashian 2015-07-18 00:44:38 UTC
I had noticed this and hinted at it in #38837. This is indeed an issue for large documents as the UI freezes for a second or two every so often (due to high cpu usage on the main thread). This issue exists in 4.4.4.3.
Comment 4 Michael Meeks 2015-07-20 09:03:57 UTC
The issue in 4.4.4.x would be not quite so bad I think - since the idle handler wont' be nearly as active - but will still be consuming CPU. I guess it prolly depends how long the paragraph is there though ;-) with a multi-page mixed-language paragraph I imagine we could see this bite us in old versions too.
Comment 5 Jean-Baptiste Faure 2015-08-16 19:56:20 UTC
*** Bug 93261 has been marked as a duplicate of this bug. ***
Comment 6 Commit Notification 2015-08-18 19:44:44 UTC
Ashod Nakashian committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=032e251f0fb80bb2400804d13a2a954cdaedf605

tdf#92036 - Writer infinite spelling loop

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Michael Stahl (allotropia) 2015-09-08 17:42:32 UTC
i'm afraid the infinite loop is intentional:

 bool SwWrongList::Fresh( sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nPos,
                             sal_Int32 nLen, sal_uInt16 nIndex, sal_Int32 nCursorPos )
 {
    // length of word must be greater than 0 and cursor position must be outside the word
    bool bRet = nLen && ( nCursorPos > nPos + nLen || nCursorPos < nPos );


the shell cursor is positioned at the end of the word, and we don't
add the word to the wrong-list yet so we don't annoy the user
who doesn't want a word underlined in red that is still being typed in.

so every iteration of the idle loop checks the paragraph again in the hope that the word is now complete, or the cursor has moved outside the paragraph.

we can invalidate the paragraph easily when text is inserted (and we do),
and we could invalidate the paragraph when the shell cursor moves to
another one, but the moving away sounds a bit more difficult to detect.
Comment 8 Commit Notification 2015-09-09 12:15:23 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4c91e94e892943ef5e031d65f6f42864233cb4cd

tdf#92036: sw: fix idle spelling loop

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Michael Stahl (allotropia) 2015-09-09 12:28:02 UTC
more useful things to know: if you have a grammar checker enabled the grammar checking thread will call SwPageFrm::ValidateSpelling() via SwXFlatParagraphIterator::getNextPara() and that terminates the idle spelling loop.

found a way to fix the idle spelling loop, even without relying on grammar checking.
Comment 10 Commit Notification 2015-09-12 11:20:45 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e5544e485f8b82612a909568174b8ad142bed54e&h=libreoffice-5-0

tdf#92036: sw: fix idle spelling loop

It will be available in 5.0.3.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.