Bug Hunting Session
Bug 127786 - LibreOffice hangs for a few seconds clicking on the title/subtitle textboxes (ca-ES-valencia)
Summary: LibreOffice hangs for a few seconds clicking on the title/subtitle textboxes ...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
6.3.1.2 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:6.4.0 target:6.3.3 target:6.2.8
Keywords: perf
Depends on:
Blocks:
 
Reported: 2019-09-26 12:57 UTC by Xisco Faulí
Modified: 2019-10-08 09:53 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
perf flamegraph (234.70 KB, application/x-bzip)
2019-09-26 18:45 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2019-09-26 12:57:25 UTC
Steps to reproduce:
1. Launch Impress using ca-ES-valencia locale ( not happening using ca-ES )
2. Click on the title/subtitle textbox
3. LibreOffice hangs for a few seconds

Surprisingly, it's only happening with ca-ES-valencia locale

Reproduced in

Versió: 6.3.1.2
ID de la construcció: 1:6.3.1~rc2-0ubuntu0.18.04.1~lo1
Fils de CPU: 4; SO: Linux 4.15; Renderitzador de la IU: per defecte; VCL: gtk3; 
Configuració local: es-ES (ca_ES.UTF-8); Llengua de la IU: ca-ES-valencia
Calc: threaded
Comment 1 Xisco Faulí 2019-09-26 13:07:53 UTC
Actually, it happens when the UI is in ca-ES-valencia, not when the locale is in ca-ES-valencia
Comment 2 Xisco Faulí 2019-09-26 13:12:14 UTC
Also reproducible in a local build using --with-lang=ca-valencia

Versió: 6.4.0.0.alpha0+
ID de la construcció: 586de7ac433dca98edf4a5a3d13b5e393b9880ed
CPU threads: 4; OS: Linux 4.15; UI render: per defecte; VCL: gtk3; 
Configuració local: en-US (ca_ES.UTF-8); UI-Language: ca-ES-valencia
Calc: threaded
Comment 3 Xisco Faulí 2019-09-26 13:13:23 UTC
Hi Julien,
Any chance you could get a perf chart here ?
Comment 4 Xisco Faulí 2019-09-26 13:19:36 UTC Comment hidden (obsolete)
Comment 5 Xisco Faulí 2019-09-26 13:20:28 UTC Comment hidden (obsolete)
Comment 6 Julien Nabet 2019-09-26 13:56:38 UTC
(In reply to Xisco Faulí from comment #3)
> Hi Julien,
> Any chance you could get a perf chart here ?

Ok but I hope I'll find the way to use "ca-ES-valencia" easily without rebuilding from scratch since it may require to add some language in autogen.input.
Comment 7 Xisco Faulí 2019-09-26 13:58:46 UTC
(In reply to Julien Nabet from comment #6)
> (In reply to Xisco Faulí from comment #3)
> > Hi Julien,
> > Any chance you could get a perf chart here ?
> 
> Ok but I hope I'll find the way to use "ca-ES-valencia" easily without
> rebuilding from scratch since it may require to add some language in
> autogen.input.

I also rebuilt Libo with --with-lang=ca-valencia, and it took me 3 minutes...
Comment 8 Julien Nabet 2019-09-26 14:05:07 UTC
Great if it works without rebuilding the whole sources!
Comment 9 Julien Nabet 2019-09-26 18:45:48 UTC
Created attachment 154560 [details]
perf flamegraph

On pc Debian x86-64 with master sources updated today + enable-symbols + ca-valencia locale, I could reproduce this.
I attached Flamegraph
Comment 10 Xisco Faulí 2019-09-27 12:23:56 UTC
(In reply to Julien Nabet from comment #9)
> Created attachment 154560 [details]
> perf flamegraph
> 
> On pc Debian x86-64 with master sources updated today + enable-symbols +
> ca-valencia locale, I could reproduce this.
> I attached Flamegraph

Moving to NEW based on this comment
Comment 11 Xisco Faulí 2019-09-27 12:35:42 UTC
@Noel, does the perf chart gives you any clue why LibreOffice is so slow only with this UI locale ?
Comment 12 Noel Grandin 2019-09-27 12:53:45 UTC
I suspect something is going wrong with our locale caching and we are repeatedly reloading the locale.
Comment 13 Noel Grandin 2019-09-27 12:54:12 UTC
Perhaps bibisect this, could be a consequence of caolan's locale work from some time ago
Comment 14 Xisco Faulí 2019-09-27 17:17:48 UTC
(In reply to Noel Grandin from comment #13)
> Perhaps bibisect this, could be a consequence of caolan's locale work from
> some time ago

The problem with the bisect repositories is that they are only built with English UI

@Caolán, any idea about this one ?
Comment 15 Caolán McNamara 2019-09-27 18:44:00 UTC
Possibly unotools/source/i18n/resmgr.cxx Translate::Create is the thing to look at here. We are caching on rLocale.getGlibcLocaleString() which I'm guessing is slow for this language variant case, in which case simply caching on the input rLocale or rLocale.getBcp47() might be the way to go
Comment 16 Eike Rathke 2019-09-27 19:06:40 UTC
The massive amount of lt_tag_convert_to_locale() calls from LanguageTagImpl::getGlibcLocaleString() (called from SvxResId/SvxResLocale) and the time spent therein looks fishy. This wasn't a problem when string resources came from the old resource system as conversion to the Glibc string wasn't needed often, but now for .po files the conversion is needed for each resource string which it wasn't before. The Glibc string can be constructed much quicker for locales that do not involve a Script tag or @modifier in the Glibc representation and LanguageTagImpl::getGlibcLocaleString() isn't even called then, hence it affects only ca-ES-valencia (ca_ES@valencia) and a few others.

We probably want to cache the Glibc string in class LanguageTagImpl. Taking.
Comment 17 Commit Notification 2019-09-27 23:20:28 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/24c7c12224f1c1d66f335f6fe085595352137646

Resolves: tdf#127786 cache Glibc locale string in LanguageTagImpl

It will be available in 6.4.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 18 Eike Rathke 2019-09-27 23:22:18 UTC
Pending review https://gerrit.libreoffice.org/79775 for 6-3
Comment 19 Xisco Faulí 2019-09-28 09:22:49 UTC
Verified in in local build including https://git.libreoffice.org/core/commit/24c7c12224f1c1d66f335f6fe085595352137646.
@Eike, thanks for fixing this issue!!

Do you think it would be good to backport it to 6-2-8 as well?
Comment 20 Commit Notification 2019-09-28 09:24:20 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

https://git.libreoffice.org/core/commit/99782b52c3cc25a32661c382ca98a32f6ec87003

Resolves: tdf#127786 cache Glibc locale string in LanguageTagImpl

It will be available in 6.3.3.

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 21 Eike Rathke 2019-09-30 14:42:07 UTC
(In reply to Xisco Faulí from comment #19)
> Do you think it would be good to backport it to 6-2-8 as well?
Theoretically yes, but as always, 6.2.8 will be the last 6.2.x release, so if anything goes wrong.. it should not, but.. ;-)
Comment 22 Commit Notification 2019-10-03 09:01:36 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

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

Resolves: tdf#127786 cache Glibc locale string in LanguageTagImpl

It will be available in 6.2.9.

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 23 Commit Notification 2019-10-08 09:53:10 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-2-8":

https://git.libreoffice.org/core/commit/5fec105e6de0005918e9f6f69aafe7ec51a9998f

Resolves: tdf#127786 cache Glibc locale string in LanguageTagImpl

It will be available in 6.2.8.

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.