Bug 143257 - [GTK] selecting a shape increases memory use up to 1.3 GB, creates visual artifacts in GUI
Summary: [GTK] selecting a shape increases memory use up to 1.3 GB, creates visual art...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.3.0 target:7.2.0.2
Keywords:
Depends on:
Blocks: GTK3 Memory
  Show dependency treegraph
 
Reported: 2021-07-08 11:53 UTC by Stéphane Guillou (stragu)
Modified: 2021-07-18 18:33 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
visual artifacts in UI (95.91 KB, image/png)
2021-07-08 11:58 UTC, Stéphane Guillou (stragu)
Details
i confirm the bug. if computer has less then 4g free libreoffice shuts down. if not it waits and work. i see it consuming memory of the pc. (308.17 KB, image/png)
2021-07-08 12:35 UTC, paulo g.
Details
is going to consume memory... (21.46 KB, image/png)
2021-07-08 13:03 UTC, paulo g.
Details
start memory (7.02 KB, image/png)
2021-07-08 13:04 UTC, paulo g.
Details
end memory 6,6 gb (7.07 KB, image/png)
2021-07-08 13:05 UTC, paulo g.
Details
memory going up (80.54 KB, image/png)
2021-07-08 13:57 UTC, BogdanB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stéphane Guillou (stragu) 2021-07-08 11:53:28 UTC
Description:
Clicking on the shape in attachment 173084 [details] ("circular-arrow" saved to .doc) increases the RAM use of LibreOffice up to 1.3 GB, eventually makes the shape disappear, and creates visual artifacts all over LibreOffice.

Is this a "memory leak"?

This is possibly only a Linux thing. It was originally reported in Bug 142983 but is probably better reported as a separate issue to the malformed shape in DOC.

Steps to Reproduce:
Use all steps here, or use the attached document and start at step 4:

1. Open attachment 173084 [details]
2. Click on the shape

Actual Results:
Clicking the shape brings up memory use of LibreOffice between 900 mb and 1.3 GB of memory (depending on version), and hangs the system for a few seconds. Memory use goes back down after a while. In some more recent versions, the shape then disappears. Clicking the area where the shape was will select the invisible object once more, and will bring the memory use up once more. Some visual artifacts might appear in the viewport, in menus, the sidebar, dialogues...

See an example video in attachment 173085 [details].

Expected Results:
Memory use does not increase dramatically, shape does not disappear, UI does not look broken.


Reproducible: Always


User Profile Reset: No



Additional Info:
I am wondering if this has to do with the fact that the malformed shape overflows possibly infinitely to the left side of the document?

Shape only disappears in 7.2 beta1 and 7.3 alpha0.

Tested in:

Version: 6.2.5.2
Build ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: en-AU (en_AU.UTF-8); UI-Language: en-US
Calc: threaded

Version: 7.0.6.2
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 7.1.4.2 / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 7.2.0.0.beta1 / LibreOffice Community
Build ID: c6974f7afec4cd5195617ae48c6ef9aacfe85ddd
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 822f128e734f37ee4de9bf5b62640cbec140701e
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
(built today)
Comment 1 Stéphane Guillou (stragu) 2021-07-08 11:58:58 UTC
Created attachment 173446 [details]
visual artifacts in UI

A screenshot of visual artifacts seen when continuing using Writer after the memory issue.
Comment 2 paulo g. 2021-07-08 12:35:27 UTC
Created attachment 173450 [details]
i confirm the bug. if computer has less then 4g free libreoffice shuts down. if not it waits and work. i see it consuming memory of the pc.
Comment 3 paulo g. 2021-07-08 13:03:30 UTC
Created attachment 173453 [details]
is going to consume memory...
Comment 4 paulo g. 2021-07-08 13:04:13 UTC
Created attachment 173454 [details]
start memory
Comment 5 paulo g. 2021-07-08 13:05:07 UTC
Created attachment 173455 [details]
end memory 6,6 gb
Comment 6 paulo g. 2021-07-08 13:07:48 UTC
Comment on attachment 173455 [details]
end memory 6,6 gb

6,6 - 3,8 = 2,8
it consumes 2,8gb gb memory...
Comment 7 BogdanB 2021-07-08 13:57:18 UTC
Created attachment 173457 [details]
memory going up

Confirm also with
Version: 7.1.4.2 / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: en-US (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 8 BogdanB 2021-07-08 13:58:53 UTC
Also in
Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: eac5977bfc11797eda356560a5e45c51108ef5a1
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 9 Stéphane Guillou (stragu) 2021-07-08 22:03:57 UTC
Thanks Paulo and Bogdan!
Seems to be GTK-specific. I tried without GTK:

/opt/libreofficedev7.2/program/soffice -env:SAL_USE_VCLPLUGIN=gen --writer

...and didn't get the same drastic increase in memory use (it only went from 100 to 150 mb, I could move the shape around, it didn't disappear...

I could see in the terminal the following warning pop up every time I move the shape around, in case it helps understanding the issue:

warn:legacy.osl:20977:20977:svx/source/svdraw/svdmrkv1.cxx:311: SdrMarkView::UndirtyMrkPnt(): Selected points on an object that is not a PolyObj!
Comment 10 Caolán McNamara 2021-07-09 16:15:59 UTC
I don't think isn't a gtk think but is a generic unix/X thing in that selecting the shape makes it a candidate for the "primary selection" and for some (rather odd look reason) we're generating a huge bitmap from it in case we want to paste it into some other application while the usual pattern is just to state that its possible to paste as that format and not generate it until its explicitly requested.
Comment 11 Caolán McNamara 2021-07-12 10:20:02 UTC
I think we can defer creating this large transfer bitmap until the moment something actually wants it during a drop, which is the usual pattern for this sort of thing and what I see we're doing with the standard writer images (as opposed to these drawings)
Comment 12 Commit Notification 2021-07-13 08:01:16 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2012d5b90b64cb3a28862267dafb162c2f85d832

tdf#143257 like graphics defer creating transfer data for drawings until needed

It will be available in 7.3.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 13 Caolán McNamara 2021-07-13 08:04:50 UTC
fixed in devel, backports in gerrit
Comment 14 Commit Notification 2021-07-16 15:13:58 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

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

tdf#143257 like graphics defer creating transfer data for drawings until needed

It will be available in 7.2.0.2.

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 15 BogdanB 2021-07-16 18:41:42 UTC
No problem now. Thanks for this fix. Very important!

Verified with Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: c6695a4aabeaae99174b7658f2b813788ecff7f0
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 16 Stéphane Guillou (stragu) 2021-07-18 06:53:02 UTC
Thank you, Caolán! No memory increase when selecting the shape in a recent build of master.

Now, if the shape is copied, we still get the memory increase, and I can see the UI issues in Writer. Should a different bug report be opened about this, that would probably apply to any operating system?
What do you think is the reason for that particular shape to hog memory like that when copied? Is it just that it is huge in size, and therefore we only need Bug 142983?
FYI, when pasted into Inkscape, the size of the object is about 587 × 182 cm.
Comment 17 Caolán McNamara 2021-07-18 18:33:48 UTC
(In reply to stragu from comment #16)
> Should a different bug report be opened about this, that would probably apply to any operating system?

It would presumably affect all platforms by the time of paste

> What do you think is the reason for that particular shape to hog memory like
> that when copied?

I don't really know, but problems like this have shown up in the past with things like very long dashed/dotted lines which, while they might get cropped in the end, generate large amount of line segments.