Bug 147802 - Clicking on header or footer area in long writer document takes a long time and slows down text selection and closing document
Summary: Clicking on header or footer area in long writer document takes a long time a...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.5.2 release
Hardware: All All
: medium minor
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.5.0 target:7.4.4
Keywords: bibisected, bisected, perf, regression
: 152019 152647 (view as bug list)
Depends on:
Blocks: Writer-Header-Footer Selection
  Show dependency treegraph
 
Reported: 2022-03-06 15:34 UTC by ratatoeskr
Modified: 2023-01-17 09:31 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Graphs from Callgrind analysis (70.24 KB, application/octet-stream)
2022-03-06 15:35 UTC, ratatoeskr
Details
Sample document with 500 pages (49.75 KB, application/vnd.oasis.opendocument.text-flat-xml)
2022-03-06 15:38 UTC, ratatoeskr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ratatoeskr 2022-03-06 15:34:01 UTC
Description:
When clicking on the area of a header or footer in a long (my sample: 500 pages) writer document, it takes a long time (several seconds on my machine) until the divider line and the button to create a header or footer appears.

Anytime after having clicked on the header or footer area (regardless whether an actual header or footer was created), this is also slow. While the caret follows the mouse during the selection without any noticeable delay, there is an initial delay of a few seconds until the highlighting of the selected text is visible. After this initial delay, moving the mouse (without releasing the mouse button) updates the highlighting without any noticeable delay.

Selecting text using the keyboard (shift + arrow keys) is unaffected by this slowdown or delay.

Also after having clicked on the header or footer area, closing the document takes a lot longer.

Closing and reopening the document restores the initial behaviour.

When having the same document open in two separate windows, clicking the header/footer area in one window does not affect selecting text in another window.

Enabling or disabling hardware acceleration or anti-aliasing makes no difference.

Steps to Reproduce:
1. Create a "long" writer document (my sample: 500 pages). Adding forced page breaks is sufficient, the amount of text, formatting etc. is unimportant.
2. Click on the header or footer area of any page of the document.
3. Select any text anywhere in the document (not inside a header or footer) with the mouse.

Actual Results:
There is a significant delay until the divider or the button to create a header/footer appears.

There is a significant delay until the selected text is highlighted.

Expected Results:
There is no significant delay when clicking on the header/footer area when comparing to a short document.

There is no significant delay when selecting text as compared to doing so in the same document without having previously clicked on the header/footer area.


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
This occurs for me in 7.2.5.2 on arch. I also compiled LibreOffice from source (master as of commit 05502f78ed0d406ff50d43a39c05f7bb990001e9) and experienced the same behaviour.

I followed the guide for Performance debugging using Callgrind and will attach some graphs.

What I can see from those when comparing a run where I clicked on the header area with a run where I didn't, selecting text and closing the document causes 500 calls (one for each page I suspect) to SwHeaderFooterWin::LinkStubFaderHandler(void*, Timer*) which take up about 80 % of the time spent selecting text or about 16 % when closing the document.
Comment 1 ratatoeskr 2022-03-06 15:35:38 UTC
Created attachment 178681 [details]
Graphs from Callgrind analysis
Comment 2 ratatoeskr 2022-03-06 15:38:22 UTC
Created attachment 178682 [details]
Sample document with 500 pages
Comment 3 Dieter 2022-03-21 07:14:51 UTC
Thank you for reporting the bug. Could you please try to reproduce it with the latest version of LibreOffice from https://www.libreoffice.org/download/libreoffice-fresh/ ? I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' if the bug is still present in the latest version. Change to RESOLVED WORKSFORME, if the problem went away.
Comment 4 ratatoeskr 2022-03-21 09:15:23 UTC
I just checked version 7.3.1 and the behaviour with the attached sample document is the same.
Comment 5 Dieter 2022-03-23 16:20:12 UTC
I confirm it with

Version: 7.3.1.3 (x64) / LibreOffice Community
Build ID: a69ca51ded25f3eefd52d7bf9a5fad8c90b87951
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL

A significant delay until the divider or the button to create a header/footer appears.

A (short) delay until the selected text is highlighted.
Comment 6 Stéphane Guillou (stragu) 2022-11-14 10:07:42 UTC
*** Bug 152019 has been marked as a duplicate of this bug. ***
Comment 7 Stéphane Guillou (stragu) 2022-11-14 10:22:29 UTC
Bibisected to following commit:

commit 51379fb3d46e5891bdaea0122bd62b0753663da3	
author	Caolán McNamara <caolanm@redhat.com>	Thu Dec 03 15:54:45 2020 +0000
committer	Caolán McNamara <caolanm@redhat.com>	Fri Dec 04 15:57:41 2020 +0100
tree 6c9e85ed41e6999bb3d9c5331da05dee2141ef0b
parent 30c54afbf5bf03da27db7f90b518817cd05e8ccd 

weld writer's FrameControl MenuButtons

Change-Id: I507b043672ffd102f85110bed221a05b756500db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107174
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>

Bisect log:

# bad: [9dcd4f5671896db03d3bf94bbe602d58585b67e7] source ffa09959edd087794b1f2fe6b9b6faac484ef74b
# good: [1810f056660f59f79e76b8bdd6f5b902c27ce14f] source 738bcf5e9a8c443d60c29c3a8068e8c16c72638a
git bisect start 'origin/master' 'oldest'
# bad: [b58e2a603efc8e9597cd1bf963c7b2dbdbf58b3a] source c6e3fcfbb901c46191461d1a08cf0c4524729cfc
git bisect bad b58e2a603efc8e9597cd1bf963c7b2dbdbf58b3a
# bad: [3706e5dd09070b0a0928311d833790432f7c023f] source 6220d619b42b18cca7280174daed56aad5c82fce
git bisect bad 3706e5dd09070b0a0928311d833790432f7c023f
# bad: [4daca39025857f4cc852b58d02996d67cf4d861d] source ff804ebff0c94e8780f01dde80c402afd3a5d208
git bisect bad 4daca39025857f4cc852b58d02996d67cf4d861d
# bad: [e8c08e55556609dc513ea2403ff2b46bf0e9b397] source 22c7ad49679c2abcac4409c93d32b20746b16904
git bisect bad e8c08e55556609dc513ea2403ff2b46bf0e9b397
# good: [2966d9509f1cd2043652c6857f5eb4ff3956282f] source e99897ff2854c1f37bbbe3cc7bf8738495403f6e
git bisect good 2966d9509f1cd2043652c6857f5eb4ff3956282f
# good: [8ba294f14739495e5e7348c5e510a5bade04fb37] source 55d4c6cfe5bd9b737698c6cd1f28ee8234abb5d0
git bisect good 8ba294f14739495e5e7348c5e510a5bade04fb37
# good: [75ecbad2f3c33add82c2cfc4d82ec90c74a66e61] source 8a4d1cc66bc728c68002a415e5aecabbf5ec433b
git bisect good 75ecbad2f3c33add82c2cfc4d82ec90c74a66e61
# good: [cffb6f488e4ce3675ee12cb5f58a1e86c4596198] source 7898eddf919a30f03a2224adbc16db4ce4bac8e5
git bisect good cffb6f488e4ce3675ee12cb5f58a1e86c4596198
# good: [58920ddfbfbfe9809e1d2bf2dafd9687fc428d5d] source daf2a7d957c829c551754871a3545495c0f76bc0
git bisect good 58920ddfbfbfe9809e1d2bf2dafd9687fc428d5d
# good: [59cea4867ab6e580f4bc3e38eae330abd9f3c0ad] source 6928bd3d6ecf9b3f64946b2b4ae021359c9fc4ba
git bisect good 59cea4867ab6e580f4bc3e38eae330abd9f3c0ad
# good: [5c9117d8102f2944828d4c28b596e969fe89918c] source b760e1f28840ae5ecce0c00201fa058c17334203
git bisect good 5c9117d8102f2944828d4c28b596e969fe89918c
# bad: [8f7e28c52195ffccc1b350daaa9e703377245cc6] source 51379fb3d46e5891bdaea0122bd62b0753663da3
git bisect bad 8f7e28c52195ffccc1b350daaa9e703377245cc6
# good: [b54ce0498a700a616a64d43780bccb3befc775e7] source 30c54afbf5bf03da27db7f90b518817cd05e8ccd
git bisect good b54ce0498a700a616a64d43780bccb3befc775e7
# first bad commit: [8f7e28c52195ffccc1b350daaa9e703377245cc6] source 51379fb3d46e5891bdaea0122bd62b0753663da3

Caolán, could you please have a look?
Comment 8 Caolán McNamara 2022-11-14 13:18:24 UTC
https://gerrit.libreoffice.org/c/core/+/142708 for the aspect where "after having clicked on the header or footer area ... there is an initial delay of a few seconds until the highlighting of the selected text is visible"
Comment 9 Commit Notification 2022-11-14 16:38:27 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b8850fe1d7dc86009516352c796619b33856141c

tdf#147802 don't trigger fade timer already shown/hidden

It will be available in 7.5.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 10 Commit Notification 2022-11-15 19:35:41 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/701e8d06484fb8781e43017ccf4ac1a3d64ac9e8

Resolves: tdf#147802 don't create a header/footer control for every page

It will be available in 7.5.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 11 Caolán McNamara 2022-11-15 19:38:27 UTC
seems good to me in gtk3 and gen in trunk now, backport to 7-4 in gerrit
Comment 12 Commit Notification 2022-11-16 13:24:34 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/27ed81d01c9d7cb55506f86fc24268ca3589e935

Resolves: tdf#147802 don't create a header/footer control for every page

It will be available in 7.4.4.

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 13 Stéphane Guillou (stragu) 2022-11-17 10:04:24 UTC
Fabulous, thank you Caolán!
Fix verified in:

Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a81e957f5026373f3935390c786c21416fc74fcc
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 14 Stéphane Guillou (stragu) 2022-12-26 12:36:29 UTC
*** Bug 152647 has been marked as a duplicate of this bug. ***