Bug 114197 - Handling large EMF document stalls LO for several minutes
Summary: Handling large EMF document stalls LO for several minutes
Status: RESOLVED DUPLICATE of bug 45820
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: filter:emf, haveBacktrace, perf
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
Reported: 2017-12-01 19:18 UTC by Mason
Modified: 2017-12-09 22:23 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:

Problem EMF compressed with 7zip (571.48 KB, application/x-7z-compressed)
2017-12-01 19:19 UTC, Mason
Problem EMF embedded in odg (1.39 MB, application/vnd.oasis.opendocument.graphics)
2017-12-01 19:21 UTC, Mason
Problem EMF embedded in odt (1.39 MB, application/vnd.oasis.opendocument.text)
2017-12-01 19:29 UTC, Mason
Problem EMF as PNG (288.88 KB, image/png)
2017-12-01 19:31 UTC, Mason
VerySleepy profiler screenshot (138.89 KB, image/png)
2017-12-03 07:22 UTC, Aron Budea
LO 4.2.8 profile (7.06 KB, text/plain)
2017-12-05 13:13 UTC, Mason
LO 5.4.3 profile (6.33 KB, text/plain)
2017-12-05 13:14 UTC, Mason
Callgrind output from master (4.88 MB, application/x-xz)
2017-12-08 18:09 UTC, Buovjaga
StackTrace WinDbg_x86 of 2017-11-01 TB39 build (27.39 KB, text/plain)
2017-12-08 23:20 UTC, V Stuart Foote

Note You need to log in before you can comment on or make changes to this bug.
Description Mason 2017-12-01 19:18:35 UTC
I was sent a document (created by an old version of MS Office) which embedded a large EMF document (49 MB when uncompressed) as a logo. Trying to open that document stalled LO 5.4.3 for over 30 minutes. And anytime I would try to scroll in the document, LO would stall again for minutes.

On IRC, someone managed to extract the EMF document, which I'll attach to this bug report.

Steps to Reproduce:
Try to import the EMF document into a new document.

Actual Results:  
LO stalls for several minutes.

Expected Results:
LO should gracefully handle the logo, or refuse to load it.

Reproducible: Always

User Profile Reset: No

Additional Info:

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Mason 2017-12-01 19:19:48 UTC
Created attachment 138167 [details]
Problem EMF compressed with 7zip
Comment 2 Mason 2017-12-01 19:21:33 UTC
Created attachment 138168 [details]
Problem EMF embedded in odg

Loading takes several minutes. Scrolling up and down stalls LO as well.
Comment 3 Mason 2017-12-01 19:29:19 UTC
Created attachment 138169 [details]
Problem EMF embedded in odt
Comment 4 Mason 2017-12-01 19:31:33 UTC
Created attachment 138170 [details]
Problem EMF as PNG
Comment 5 Aron Budea 2017-12-01 19:37:18 UTC
Confirmed with a 6.0 daily build from a few days ago / Windows 7.
Comment 6 Mason 2017-12-01 20:00:06 UTC
EMF = Enhanced Metafile
Comment 7 Telesto 2017-12-01 22:49:37 UTC
Also in
Versie (Bouw-id: 7545bee9c2a0782548772a21bc84a9dcc583b89)
Comment 8 Aron Budea 2017-12-03 07:22:43 UTC
Created attachment 138188 [details]
VerySleepy profiler screenshot

Attaching a screenshot of VerySleepy profile results (measured for 100s after inserting the image), it points to basegfx polygon-handling code.
Comment 9 Mason 2017-12-05 13:10:11 UTC
I have used
    perf record -e cycles -c 1000000 libreoffice problem.odt
to profile LO 4.2.8 and LO 5.4.3 when opening problem.odt


1) LO 5.4.3 is 60% slower than LO 4.2.8 (performance regression?)

2) there are non-trivial differences between the two profiles
=> rtl_math_approxEqual() added in LO 5.4.3

I will attach the two profiles.
Comment 10 Mason 2017-12-05 13:13:26 UTC
Created attachment 138226 [details]
LO 4.2.8 profile
Comment 11 Mason 2017-12-05 13:14:35 UTC
Created attachment 138227 [details]
LO 5.4.3 profile
Comment 12 Buovjaga 2017-12-08 18:09:11 UTC
Created attachment 138322 [details]
Callgrind output from master

Took it from opening the .odg

Arch Linux 64-bit
Build ID: a9a4c26ed1365ffa089654fefc8fa2f29862b6c7
CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group threaded
Built on December 7th 2017
Comment 13 V Stuart Foote 2017-12-08 23:19:44 UTC
Looks to be a dupe of see also bug 45820

WinDbg stack trace on filter insert to Draw canvas. Grinding away at b2dclipstate and b2dpolypolycutter...
Comment 14 V Stuart Foote 2017-12-08 23:20:35 UTC
Created attachment 138324 [details]
StackTrace WinDbg_x86 of 2017-11-01 TB39 build
Comment 15 Buovjaga 2017-12-09 22:23:58 UTC
Yep, let's dupe to it.

*** This bug has been marked as a duplicate of bug 45820 ***