Bug 102354 - Text auto-fit / de-composition - hyper expensive ...
Summary: Text auto-fit / de-composition - hyper expensive ...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
5.1.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
Depends on:
Blocks: Textbox
  Show dependency treegraph
 
Reported: 2016-09-22 08:47 UTC by Michael Meeks
Modified: 2023-09-30 01:51 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
test ODP (33.34 KB, application/vnd.oasis.opendocument.presentation)
2023-09-29 23:00 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2016-09-22 08:47:58 UTC
Some interesting performance problems with impress. Create a file with an auto-fit text box containing two dozen rows of 'test Test Test test.' in a smallish font size - say 6 point.

Now try to click into it to edit / select it. It takes an amazingly long time - several seconds of hard work. No profile here, but typing 'finish' in gdb - which shows some fun:

#37 0x00007f104a72c9d3 in GetTextEditBackgroundColor(SdrObjEditView const&) () from /opt/collaboraoffice5.1/program/libmergedlo.so

which returns just a color:

include/svx/svdetc.hxx:SVX_DLLPUBLIC Color GetTextEditBackgroundColor(const SdrObjEditView& rView);

Appears to do a full de-composition of the shape, and worse re-auto-fits it as we do it [ surely we do that just once when we first layout a shape ? ;-] it appears to take 500ms for me in the debugger ( not scientific ).

Interesting trace here:

Thread 2 (Thread 0x7f1014f69700 (LWP 23816)):
#0  0x00007f10479974e0 in u_getCombiningClass_56 () from /opt/collaboraoffice5.1/program/libicuuc.so.56
#1  0x00007f104bb0c21f in hb_icu_unicode_combining_class(hb_unicode_funcs_t*, unsigned int, void*) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#2  0x00007f104bac5ea1 in hb_unicode_funcs_t::combining_class(unsigned int) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#3  0x00007f104baf6538 in hb_unicode_funcs_t::modified_combining_class(unsigned int) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#4  0x00007f104baf412a in _hb_glyph_info_set_unicode_props(hb_glyph_info_t*, hb_unicode_funcs_t*) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#5  0x00007f104baf4bb5 in hb_set_unicode_props(hb_buffer_t*) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#6  0x00007f104baf5f73 in hb_ot_shape_internal(hb_ot_shape_context_t*) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#7  0x00007f104baf6084 in _hb_ot_shape () from /opt/collaboraoffice5.1/program/libmergedlo.so
#8  0x00007f104bac432d in hb_shape_plan_execute () from /opt/collaboraoffice5.1/program/libmergedlo.so
#9  0x00007f104bac37e8 in hb_shape_full () from /opt/collaboraoffice5.1/program/libmergedlo.so
#10 0x00007f104bac3844 in hb_shape () from /opt/collaboraoffice5.1/program/libmergedlo.so
#11 0x00007f104b0c9112 in HbLayoutEngine::Layout(ServerFontLayout&, ImplLayoutArgs&) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#12 0x00007f104aef4793 in OutputDevice::ImplLayout(rtl::OUString const&, int, int, Point const&, long, long const*, SalLayoutFlags, vcl::TextLayoutCache const*) const () from /opt/collaboraoffice5.1/program/libmergedlo.so
#13 0x00007f104aef49e1 in OutputDevice::GetTextArray(rtl::OUString const&, long*, int, int, vcl::TextLayoutCache const*) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#14 0x00007f104994c100 in SvxFont::QuickGetTextSize(OutputDevice const*, rtl::OUString const&, int, int, long*) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#15 0x00007f104990ecbf in ImpEditEngine::CreateLines(int, unsigned int) () from /opt/collaboraoffice5.1/program/libmergedlo.so

    slow to finish this ...

#16 0x00007f1049910b51 in ImpEditEngine::FormatDoc() () from /opt/collaboraoffice5.1/program/libmergedlo.so
#17 0x00007f1049914e44 in ImpEditEngine::FormatAndUpdate(EditView*) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#18 0x00007f10498d3f75 in EditEngine::SetUpdateMode(bool) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#19 0x00007f104a7b6ec5 in SdrTextObj::impDecomposeAutoFitTextPrimitive(com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> >&, drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D const&, drawinglayer::geometry::ViewInformation2D const&) const
    () from /opt/collaboraoffice5.1/program/libmergedlo.so
#20 0x00007f104a6d34d0 in drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const () from /opt/collaboraoffice5.1/program/libmergedlo.so
#21 0x00007f1049805502 in drawinglayer::primitive2d::BufferedDecompositionPrimitive2D::get2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const () from /opt/collaboraoffice5.1/program/libmergedlo.so
---Type <return> to continue, or q <return> to quit---
#22 0x00007f104a6d2bec in drawinglayer::primitive2d::SdrTextPrimitive2D::get2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const () from /opt/collaboraoffice5.1/program/libmergedlo.so
#23 0x00007f10498066aa in drawinglayer::primitive2d::BasePrimitive2D::getB2DRange(drawinglayer::geometry::ViewInformation2D const&) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so

	slow to finish this ...

#24 0x00007f104980575a in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DReference(com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> const&, drawinglayer::geometry::ViewInformation2D const&) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#25 0x00007f10498058af in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> > const&, drawinglayer::geometry::ViewInformation2D const&) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#26 0x00007f10498066b8 in drawinglayer::primitive2d::BasePrimitive2D::getB2DRange(drawinglayer::geometry::ViewInformation2D const&) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#27 0x00007f104980575a in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DReference(com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> const&, drawinglayer::geometry::ViewInformation2D const&) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#28 0x00007f10498058af in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> > const&, drawinglayer::geometry::ViewInformation2D const&) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#29 0x00007f10498066b8 in drawinglayer::primitive2d::BasePrimitive2D::getB2DRange(drawinglayer::geometry::ViewInformation2D const&) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#30 0x00007f104980575a in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DReference(com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> const&, drawinglayer::geometry::ViewInformation2D const&) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#31 0x00007f10498058af in drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::graphic::XPrimitive2D> > const&, drawinglayer::geometry::ViewInformation2D const&) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#32 0x00007f104a6bdda5 in sdr::contact::ViewObjectContact::getPrimitive2DSequence(sdr::contact::DisplayInfo const&) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#33 0x00007f104a6efafa in ViewObjectContactPrimitiveHit(sdr::contact::ViewObjectContact const&, basegfx::B2DPoint const&, double, bool) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#34 0x00007f104a6effc2 in SdrObjectPrimitiveHit(SdrObject const&, Point const&, unsigned short, SdrPageView const&, SetOfByte const*, bool) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#35 0x00007f104a72c5a2 in (anonymous namespace)::impGetSdrObjListFillColor(SdrObjList const&, Point const&, SdrPageView const&, SetOfByte const&, Color&) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#36 0x00007f104a72c61b in (anonymous namespace)::impGetSdrPageFillColor(SdrPage const&, Point const&, SdrPageView const&, SetOfByte const&, Color&, bool) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#37 0x00007f104a72c9d3 in GetTextEditBackgroundColor(SdrObjEditView const&) () from /opt/collaboraoffice5.1/program/libmergedlo.so

    Slow to finish from this [!] ...

#38 0x00007f104a726211 in SdrObjEditView::ImpMakeOutlinerView(vcl::Window*, bool, OutlinerView*, SfxViewShell*) const ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#39 0x00007f104a729211 in SdrObjEditView::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool) () from /opt/collaboraoffice5.1/program/libmergedlo.so
#40 0x00007f103084d348 in sd::View::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool)
    () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#41 0x00007f103069caec in sd::FuText::SetInEditMode(MouseEvent const&, bool) () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#42 0x00007f103069d30b in sd::FuText::DoExecute(SfxRequest&) () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#43 0x00007f103082c261 in sd::DrawViewShell::FuPermanent(SfxRequest&) () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#44 0x00007f1049f2cf08 in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#45 0x00007f1049f3489e in SfxDispatcher::Execute(unsigned short, SfxCallMode, SfxPoolItem const*, ...) ()
   from /opt/collaboraoffice5.1/program/libmergedlo.so
#46 0x00007f1030696e0f in sd::FuSelection::MouseButtonDown(MouseEvent const&) () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#47 0x00007f103086a562 in sd::ViewShell::MouseButtonDown(MouseEvent const&, sd::Window*) ()
   from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#48 0x00007f1030815a68 in sd::DrawViewShell::MouseButtonDown(MouseEvent const&, sd::Window*) ()
   from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#49 0x00007f1030866f2d in sd::ViewShell::LogicMouseButtonDown(MouseEvent const&) () from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#50 0x00007f10307860ed in SdXImpressDocument::postMouseEvent(int, int, int, int, int, int) ()
   from /opt/collaboraoffice5.1/program/../program/libsdlo.so
#51 0x00007f104a1e67f9 in doc_postMouseEvent () from /opt/collaboraoffice5.1/program/libmergedlo.so
#52 0x0000000000438d5c in postMouseEvent (this=<optimized out>, nModifier=<optimized out>, nButtons=<optimized out>, nCount=<optimized out>, 
    nY=<optimized out>, nX=<optimized out>, nType=<optimized out>) at LibreOfficeKit.hpp:252
#53 ChildSession::mouseEvent (this=this@entry=0x12dfc78, tokens=...) at ChildSession.cpp:691
#54 0x0000000000442d68 in ChildSession::_handleInput (this=0x12dfc78, 
    buffer=0x7f100c000950 "mouse type=buttondown x=10864 y=7519 count=1 buttons=1 modifier=0", length=65) at ChildSession.cpp:231
#55 0x000000000044d7c2 in LOOLSession::handleInput (this=0x12dfc78, 
    buffer=0x7f100c000950 "mouse type=buttondown x=10864 y=7519 count=1 buttons=1 modifier=0", length=65) at LOOLSession.cpp:227
#56 0x0000000000423a34 in operator() (payload=..., __closure=<optimized out>) at LOOLKit.cpp:326
#57 std::_Function_handler<bool (std::vector<char, std::allocator<char> > const&), Connection::run()::{lambda(std::vector<char, std::allocator<char> > const&)#1}>::_M_invoke(std::_Any_data const&, std::vector<char, std::allocator<char> > const&) (__functor=..., __args#0=...)
    at /usr/include/c++/4.8/functional:2057
#58 0x00000000004448a9 in operator() (__args#0=..., this=0x7f1014f68c40) at /usr/include/c++/4.8/functional:2471
#59 IoUtil::SocketProcessor(std::shared_ptr<Poco::Net::WebSocket> const&, std::function<bool (std::vector<char, std::allocator<char> > const&)> const&, std::function<void ()> const&, std::function<bool ()> const&) (ws=..., handler=..., closeFrame=..., stopPredicate=...) at IoUtil.cpp:167
#60 0x000000000042c896 in Connection::run (this=0x12dfe68) at LOOLKit.cpp:335
#61 0x00007f104ef1de66 in Poco::ThreadImpl::runnableEntry (pThread=0x12dfe78) at src/Thread_POSIX.cpp:349
#62 0x00007f104da550a4 in start_thread (arg=0x7f1014f69700) at pthread_create.c:309
#63 0x00007f104d78acbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thanks ! =)
Comment 1 Xisco Faulí 2017-09-25 17:54:01 UTC
Hi Michael Meeks,
Could it be converted into an easyHack ?
Comment 2 Michael Meeks 2017-09-26 10:02:36 UTC
An easy-hack ? doesn't sound like it to me. Lots of pain up and down the stack to make this perform nicely is needed.
Comment 3 QA Administrators 2018-09-27 02:42:40 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2020-09-27 03:57:21 UTC Comment hidden (obsolete)
Comment 5 QA Administrators 2022-09-28 03:32:32 UTC Comment hidden (obsolete)
Comment 6 Stéphane Guillou (stragu) 2023-09-29 23:00:14 UTC
Created attachment 189900 [details]
test ODP

Testing with libreoffice-5.1.5.2 and the attached ODP, it's definitely struggle street and painful to watch.

However, with a recent master build, clicking, selecting and editing is pretty much instant:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e9a0c97de95688b2f86bbb4dd8c823af5442401c
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

So closing as "works for me".
Comment 7 Aron Budea 2023-09-30 01:48:51 UTC
Reverse bibisecting took me to this commit in 5.3. Not sure if it's the actual fixing commit, but here it is nevertheless.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=d82f34a7ec478bb16d6e2c2dae562bdaead4c8d5
author		Stephan Bergmann <sbergman@redhat.com>	2016-11-01 11:50:19 +0100
committer	Stephan Bergmann <sbergman@redhat.com>	2016-11-01 16:04:44 +0000

Forward debug/optimization flags to external/harfbuzz