RESOLVED FIXED 185411
[Simple line layout] Cache run and line resolvers.
https://bugs.webkit.org/show_bug.cgi?id=185411
Summary [Simple line layout] Cache run and line resolvers.
zalan
Reported 2018-05-07 20:32:56 PDT
Whenever a (run/line)resolver is constructed (for painting/hit testing) we iterate through and collect all the flow's content in FlowContents's c'tor. In case of long text content with large amount of elements (foobar1<br>foobar2<br>.....foobar9999<br>) this repeated work could hang the WebProcess.
Attachments
Patch (12.44 KB, patch)
2018-05-07 20:44 PDT, zalan
no flags
Patch (12.49 KB, patch)
2018-05-08 10:58 PDT, zalan
no flags
Patch (12.75 KB, patch)
2018-05-08 14:51 PDT, zalan
no flags
zalan
Comment 1 2018-05-07 20:44:13 PDT
Radar WebKit Bug Importer
Comment 2 2018-05-07 20:44:55 PDT
Antti Koivisto
Comment 3 2018-05-08 08:31:38 PDT
Comment on attachment 339794 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=339794&action=review > Source/WebCore/rendering/SimpleLineLayout.cpp:979 > + , m_runResolver(std::make_unique<RunResolver>(blockFlow, *this)) > + , m_lineResolver(std::make_unique<LineResolver>(*m_runResolver)) Doesn't this massively increase memory use of simple line layout? FlowContents objects have way more per-line memory use than Layout, that's why they have been temporaries so far. Can we have a cache that is created on-demand and goes away when not needed (with a timer for example).
zalan
Comment 4 2018-05-08 08:34:42 PDT
Comment on attachment 339794 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=339794&action=review >> Source/WebCore/rendering/SimpleLineLayout.cpp:979 >> + , m_lineResolver(std::make_unique<LineResolver>(*m_runResolver)) > > Doesn't this massively increase memory use of simple line layout? FlowContents objects have way more per-line memory use than Layout, that's why they have been temporaries so far. Can we have a cache that is created on-demand and goes away when not needed (with a timer for example). Absolutely! I was going to create them on demand (hence the std::unique<>). -though destroying them on a timer didn't occur to me. That's a good idea.
Antti Koivisto
Comment 5 2018-05-08 08:47:24 PDT
Actually since FlowContents::Segments are per-renderer, the resolvers are not that big in any reasonable case (and unreasonable ones benefit from caching). I think this approach is actually fine as-is. You probably don't need to cache RunResolver and LineResolver separately though.
zalan
Comment 6 2018-05-08 10:58:36 PDT
Antti Koivisto
Comment 7 2018-05-08 11:43:41 PDT
Comment on attachment 339834 [details] Patch r=me
zalan
Comment 8 2018-05-08 14:51:47 PDT
WebKit Commit Bot
Comment 9 2018-05-08 17:20:25 PDT
Comment on attachment 339885 [details] Patch Clearing flags on attachment: 339885 Committed r231529: <https://trac.webkit.org/changeset/231529>
WebKit Commit Bot
Comment 10 2018-05-08 17:20:26 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.