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.
Created attachment 339794 [details] Patch
<rdar://problem/40047659>
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).
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.
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.
Created attachment 339834 [details] Patch
Comment on attachment 339834 [details] Patch r=me
Created attachment 339885 [details] Patch
Comment on attachment 339885 [details] Patch Clearing flags on attachment: 339885 Committed r231529: <https://trac.webkit.org/changeset/231529>
All reviewed patches have been landed. Closing bug.