<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>189460</bug_id>
          
          <creation_ts>2018-09-08 21:33:24 -0700</creation_ts>
          <short_desc>run-webkit-tests --world-leaks unexpectedly says svg/text/text-text-05-t.svg leaks a document</short_desc>
          <delta_ts>2019-03-21 21:58:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>196059</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=189147</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=189459</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ddkilzer</cc>
    
    <cc>joepeck</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1458000</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-09-08 21:33:24 -0700</bug_when>
    <thetext>With the fix for bugs 189147 and bug 189459, svg/text/text-text-05-t.svg still leaks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1458001</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-09-08 21:33:49 -0700</bug_when>
    <thetext>&lt;rdar://problem/44269848&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1458002</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-09-08 21:37:36 -0700</bug_when>
    <thetext>This is going to be another retain cycle involving SVGFontFaceElement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1458005</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-09-08 22:24:39 -0700</bug_when>
    <thetext>Also involves:

3   0x3977b3d24 WTF::RefPtr&lt;WebCore::SVGFontFaceElement, WTF::DumbPtrTraits&lt;WebCore::SVGFontFaceElement&gt; &gt;::RefPtr(WebCore::SVGFontFaceElement*)
4   0x39778c25d WTF::RefPtr&lt;WebCore::SVGFontFaceElement, WTF::DumbPtrTraits&lt;WebCore::SVGFontFaceElement&gt; &gt;::RefPtr(WebCore::SVGFontFaceElement*)
5   0x39778c006 WebCore::CSSFontFaceSource::CSSFontFaceSource(WebCore::CSSFontFace&amp;, WTF::String const&amp;, WebCore::CachedFont*, WebCore::SVGFontFaceElement*, WTF::RefPtr&lt;JSC::ArrayBufferView, WTF::DumbPtrTraits&lt;JSC::ArrayBufferView&gt; &gt;&amp;&amp;)
6   0x39778c50d WebCore::CSSFontFaceSource::CSSFontFaceSource(WebCore::CSSFontFace&amp;, WTF::String const&amp;, WebCore::CachedFont*, WebCore::SVGFontFaceElement*, WTF::RefPtr&lt;JSC::ArrayBufferView, WTF::DumbPtrTraits&lt;JSC::ArrayBufferView&gt; &gt;&amp;&amp;)
7   0x39777ce66 WebCore::CSSFontFace::appendSources(WebCore::CSSFontFace&amp;, WebCore::CSSValueList&amp;, WebCore::Document*, bool)
8   0x39778f1bd WebCore::CSSFontSelector::addFontFaceRule(WebCore::StyleRuleFontFace&amp;, bool)
9   0x39778e73d WebCore::CSSFontSelector::buildCompleted()
10  0x39900b4f5 WebCore::Style::Scope::resolver()
11  0x399011e11 WebCore::Style::TreeResolver::Scope::Scope(WebCore::Document&amp;)
12  0x399011ecd WebCore::Style::TreeResolver::Scope::Scope(WebCore::Document&amp;)
13  0x399017cfa WebCore::Style::TreeResolver::resolve()
14  0x397a298e7 WebCore::Document::resolveStyle(WebCore::Document::ResolveStyleType)
15  0x397a2b423 WebCore::Document::updateStyleIfNeeded()
16  0x397a441f7 WebCore::Document::finishedParsing()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493566</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-10 19:33:05 -0800</bug_when>
    <thetext>Looks like in a manual test no documents are leaking, or at least this looks as I would expect it to look.

1. Launch MiniBrowser (webkit.org)
2. Load the test page (file:///...)
3. Navigate to about:blank
4. Take measurements

&gt;    $ notifyutil -p com.apple.WebKit.showAllDocuments
&gt;    81081  6 live pages:
&gt;    81081  Page 0x6d6dbf100 with main document 0x6eb4020f0
&gt;    81081  Page 0x6d6df9b00 with main document 0x6ea201078
&gt;    81081  Page 0x6d6dbd000 with main document 0x6eb601078
&gt;    81081  Page 0x6d6dbdb00 with main document 0x6ea2020f0
&gt;    81081  Page 0x6d6df9000 with main document 0x6ea302180 about:blank
&gt;    81081  Page 0x6d6dbe600 with main document 0x6eb401078
&gt;    81081  8 live documents:
&gt;    81081  SVGDocument 0x6eb601078 12 (refCount 1, referencingNodeCount 8)
&gt;    81081  SVGDocument 0x6eb4020f0 10 (refCount 1, referencingNodeCount 13)
&gt;    81081  SVGDocument 0x6eb6020f0 13 (refCount 3, referencingNodeCount 1018) .../LayoutTests/svg/text/text-text-05-t.svg
&gt;    81081  SVGDocument 0x6eb401078 8 (refCount 1, referencingNodeCount 5)
&gt;    81081  SVGDocument 0x6ea201078 4 (refCount 1, referencingNodeCount 9)
&gt;    81081  SVGDocument 0x6ea2020f0 6 (refCount 1, referencingNodeCount 45)
&gt;    81081  Document 0x6d68010c0 2 (refCount 6, referencingNodeCount 684) https://webkit.org/
&gt;    81081  Document 0x6ea302180 14 (refCount 2, referencingNodeCount 3) about:blank
&gt;
&gt;    $ notifyutil -p org.WebKit.lowMemory
&gt;    81081  Memory pressure relief: Total: res = 28389376/25059328/-3330048, res+swap = 26914816/23584768/-3330048
&gt;
&gt;
&gt;    $ notifyutil -p com.apple.WebKit.showAllDocuments
&gt;    81081  1 live pages:
&gt;    81081  Page 0x6d6df9000 with main document 0x6ea302180 about:blank
&gt;    81081  1 live documents:
&gt;    81081  Document 0x6ea302180 14 (refCount 2, referencingNodeCount 3) about:blank

Next step:
• Investigate when the Document gets released and ensure that `run-webkit-tests --world-leaks` doesn&apos;t have a false report for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493600</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-10 20:58:58 -0800</bug_when>
    <thetext>In MiniBrowser I see the document (SVGDocument here) going away with a memory warning when the FontCascadeCache gets purged:

&gt;     &gt;&gt;&gt; Document::~Document - 0x7833020f0
&gt;     1   0x7522f4a40 WebCore::Document::~Document()
&gt;     2   0x7522d4a95 WebCore::XMLDocument::~XMLDocument()
&gt;     3   0x753aa4325 WebCore::SVGDocument::~SVGDocument()
&gt;     4   0x753a917e5 WebCore::SVGDocument::~SVGDocument()
&gt;     5   0x753a91809 WebCore::SVGDocument::~SVGDocument()
&gt;     6   0x7522f70e2 WebCore::Document::decrementReferencingNodeCount()
&gt;     7   0x752455689 WebCore::Node::~Node()
&gt;     8   0x7522a3b17 WebCore::ContainerNode::~ContainerNode()
&gt;     9   0x7523bab1b WebCore::Element::~Element()
&gt;     10  0x752502e32 WebCore::StyledElement::~StyledElement()
&gt;     11  0x753a86129 WebCore::SVGElement::~SVGElement()
&gt;     12  0x753b537bd WebCore::SVGFontFaceElement::~SVGFontFaceElement()
&gt;     13  0x753b537e5 WebCore::SVGFontFaceElement::~SVGFontFaceElement()
&gt;     14  0x753b53809 WebCore::SVGFontFaceElement::~SVGFontFaceElement()
&gt;     15  0x75246192b WebCore::Node::removedLastRef()
&gt;     16  0x75002478d WebCore::Node::deref()
&gt;     17  0x75208b5c1 void WTF::derefIfNotNull&lt;WebCore::SVGFontFaceElement&gt;(WebCore::SVGFontFaceElement*)
&gt;     18  0x75208b589 WTF::RefPtr&lt;WebCore::SVGFontFaceElement, WTF::DumbPtrTraits&lt;WebCore::SVGFontFaceElement&gt; &gt;::~RefPtr()
&gt;     19  0x75206a0e5 WTF::RefPtr&lt;WebCore::SVGFontFaceElement, WTF::DumbPtrTraits&lt;WebCore::SVGFontFaceElement&gt; &gt;::~RefPtr()
&gt;     20  0x75206a03f WebCore::CSSFontFaceSource::~CSSFontFaceSource()
&gt;     ...
&gt;     33  0x75204c939 WebCore::CSSFontFace::~CSSFontFace()
&gt;     ...
&gt;     61  0x753120305 WebCore::FontCascadeCacheEntry::~FontCascadeCacheEntry()
&gt;     ...
&gt;     71  0x7531086b9 WebCore::pruneUnreferencedEntriesFromFontCascadeCache()
&gt;     72  0x753108107 WebCore::FontCache::purgeInactiveFontData(unsigned int)
&gt;     73  0x752e77309 WebCore::releaseNoncriticalMemory()
&gt;     74  0x752e76f81 WebCore::releaseMemory(WTF::Critical, WTF::Synchronous, WebCore::MaintainPageCache)
&gt;     75  0x10a394f48 WebKit::WebProcess::initializeWebProcess(WebKit::WebProcessCreationParameters&amp;&amp;)::$_4::operator()(WTF::Critical, WTF::Synchronous) const
&gt;     76  0x10a394ec6 WTF::Function&lt;void (WTF::Critical, WTF::Synchronous)&gt;::CallableWrapper&lt;WebKit::WebProcess::initializeWebProcess(WebKit::WebProcessCreationParameters&amp;&amp;)::$_4&gt;::call(WTF::Critical, WTF::Synchronous)
&gt;     77  0x7673f7a94 WTF::Function&lt;void (WTF::Critical, WTF::Synchronous)&gt;::operator()(WTF::Critical, WTF::Synchronous) const
&gt;     78  0x7673f75ae WTF::MemoryPressureHandler::releaseMemory(WTF::Critical, WTF::Synchronous)
&gt;     79  0x7673f9938 WTF::MemoryPressureHandler::respondToMemoryPressure(WTF::Critical, WTF::Synchronous)
&gt;     80  0x7673f7935 WTF::MemoryPressureHandler::beginSimulatedMemoryPressure()
&gt;     81  0x7673f99d6 invocation function for block in WTF::MemoryPressureHandler::install()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493601</commentid>
    <comment_count>6</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-10 20:59:28 -0800</bug_when>
    <thetext>It is interesting to note that `WebCore::FontCache::purgeInactiveFontData` purges differently in a memory warning versus WKBundleReleaseMemory based on being under real memory pressure or not:

    const unsigned cMaxInactiveFontData = 225;
    const unsigned cMaxUnderMemoryPressureInactiveFontData = 50;
    ...
    void FontCache::purgeInactiveFontDataIfNeeded()
    {
        bool underMemoryPressure = MemoryPressureHandler::singleton().isUnderMemoryPressure();
        unsigned inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData;
        ...
    }

So a MemoryWarning (which will simulate isUnderMemoryPressure) will potentially reduce the cache to 50 but a simple WKBundleReleaseMemory would aim for 225. I&apos;ll see if I force WKBundleReleaseMemory to set &quot;isUnderMemoryPressure&quot; if that helps.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493606</commentid>
    <comment_count>7</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-10 21:17:28 -0800</bug_when>
    <thetext>That wasn&apos;t enough. The SVG Document is still not getting released in tests (and still not even if I purge inactive as much as possible).

So it seems this font is probably considered active at the end of the test. That is what I&apos;ll start looking at next.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493742</commentid>
    <comment_count>8</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-11 12:11:02 -0800</bug_when>
    <thetext>Oops, that was `FontCache::purgeInactiveFontDataIfNeeded` not `FontCache::purgeInactiveFontData`, so of course it didn&apos;t matter.

Still, it is probably a good thing to make WKBundleReleaseMemory simulate a memory warning / act as if we are under memory pressure to release as much as possible. This is only used by tests anyways.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493844</commentid>
    <comment_count>9</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-11 14:54:38 -0800</bug_when>
    <thetext>When I remove the LayoutTest specific part of this test:

```
    if (window.testRunner)
        testRunner.dumpSelectionRect();
```

The test doesn&apos;t abandon a document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493847</commentid>
    <comment_count>10</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-11 15:00:28 -0800</bug_when>
    <thetext>Actually the other JavaScript:

    function repaintTest() {
        document.execCommand(&quot;SelectAll&quot;);
    }

This might make sense because often the selection goes away in MiniBrowser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1493848</commentid>
    <comment_count>11</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-11 15:01:42 -0800</bug_when>
    <thetext>Dumping the FontCascade cache, there is a single entry which is different (and has more refs).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1494905</commentid>
    <comment_count>12</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-15 16:50:41 -0800</bug_when>
    <thetext>Looks like in LayoutTests the FontCascadeFonts is held onto by the FontCascade inside of the document&apos;s StyleResolver:

    &gt;&gt;&gt; FontCascadeFonts::FontCascadeFonts(FontSelector) - 0x3ee2805a0 (1)
    1   0x3d2aa1386 WebCore::FontCascadeFonts::FontCascadeFonts(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    2   0x3d2aa151d WebCore::FontCascadeFonts::FontCascadeFonts(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    3   0x3d2aabc2f WebCore::FontCascadeFonts::create(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    4   0x3d2a984f3 WebCore::retrieveOrAddCachedFonts(WebCore::FontCascadeDescription const&amp;, WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    5   0x3d2a9831f WebCore::FontCascade::update(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;) const
    6   0x3d1b18b19 WebCore::StyleResolver::updateFont()
    7   0x3d1b16d55 WebCore::StyleResolver::applyMatchedProperties(WebCore::StyleResolver::MatchResult const&amp;, WebCore::Element const&amp;, WebCore::StyleResolver::ShouldUseMatchedPropertiesCache)
    8   0x3d1b0aeea WebCore::StyleResolver::styleForElement(WebCore::Element const&amp;, WebCore::RenderStyle const*, WebCore::RenderStyle const*, WebCore::RuleMatchingBehavior, WebCore::SelectorFilter const*)
    9   0x3d1d5181f WebCore::Element::resolveStyle(WebCore::RenderStyle const*)
    10  0x3d341c2ef WebCore::SVGElement::resolveCustomStyle(WebCore::RenderStyle const&amp;, WebCore::RenderStyle const*)
    11  0x3d3346bd2 WebCore::Style::TreeResolver::styleForElement(WebCore::Element&amp;, WebCore::RenderStyle const&amp;)
    12  0x3d33471f0 WebCore::Style::TreeResolver::resolveElement(WebCore::Element&amp;)
    13  0x3d3348af9 WebCore::Style::TreeResolver::resolveComposedTree()
    14  0x3d33498b8 WebCore::Style::TreeResolver::resolve()
    15  0x3d1c8c77a WebCore::Document::resolveStyle(WebCore::Document::ResolveStyleType)
    16  0x3d1c8d9bd WebCore::Document::updateStyleIfNeeded()
    17  0x3d1ca5730 WebCore::Document::finishedParsing()
    18  0x3d3816fe4 WebCore::XMLDocumentParser::end()
    19  0x3d38176ea WebCore::XMLDocumentParser::resumeParsing()
    20  0x3d38174ac WebCore::XMLDocumentParser::notifyFinished(WebCore::PendingScript&amp;)
    21  0x3d1e0a307 WebCore::PendingScript::notifyClientFinished()
    22  0x3d1e0a369 WebCore::PendingScript::notifyFinished(WebCore::LoadableScript&amp;)
    23  0x3d1da8ac6 WebCore::LoadableScript::notifyClientFinished()
    24  0x3d1da88b0 WebCore::LoadableClassicScript::notifyFinished(WebCore::CachedResource&amp;)
    25  0x3d26d527f WebCore::CachedResource::checkNotify()
    26  0x3d26d0591 WebCore::CachedResource::finishLoading(WebCore::SharedBuffer*)
    27  0x3d26fe9df WebCore::CachedScript::finishLoading(WebCore::SharedBuffer*)
    28  0x3d2650971 WebCore::SubresourceLoader::didFinishLoading(WebCore::NetworkLoadMetrics const&amp;)
    29  0x3c8ddef93 WebKit::WebResourceLoader::didFinishResourceLoad(WebCore::NetworkLoadMetrics const&amp;)
    30  0x3c917c1fa void IPC::callMemberFunctionImpl&lt;WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;, 0ul&gt;(WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;&amp;&amp;, std::__1::integer_sequence&lt;unsigned long, 0ul&gt;)
    31  0x3c917bfb0 void IPC::callMemberFunction&lt;WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;, std::__1::integer_sequence&lt;unsigned long, 0ul&gt; &gt;(std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;&amp;&amp;, WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;))
    
    &gt;&gt;&gt; FontCascadeFonts::ref - 0x3ee2805a0 (2)
    1   0x3d2aa1974 WebCore::FontCascadeFonts::ref() const
    2   0x3d2aadf84 WTF::Ref&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::Ref(WebCore::FontCascadeFonts&amp;)
    3   0x3d2aabb3d WTF::Ref&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::Ref(WebCore::FontCascadeFonts&amp;)
    4   0x3d2a98566 WebCore::retrieveOrAddCachedFonts(WebCore::FontCascadeDescription const&amp;, WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    5   0x3d2a9831f WebCore::FontCascade::update(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;) const
    6   0x3d1b18b19 WebCore::StyleResolver::updateFont()
    7   0x3d1b16d55 WebCore::StyleResolver::applyMatchedProperties(WebCore::StyleResolver::MatchResult const&amp;, WebCore::Element const&amp;, WebCore::StyleResolver::ShouldUseMatchedPropertiesCache)
    8   0x3d1b0aeea WebCore::StyleResolver::styleForElement(WebCore::Element const&amp;, WebCore::RenderStyle const*, WebCore::RenderStyle const*, WebCore::RuleMatchingBehavior, WebCore::SelectorFilter const*)
    9   0x3d1d5181f WebCore::Element::resolveStyle(WebCore::RenderStyle const*)
    10  0x3d341c2ef WebCore::SVGElement::resolveCustomStyle(WebCore::RenderStyle const&amp;, WebCore::RenderStyle const*)
    11  0x3d3346bd2 WebCore::Style::TreeResolver::styleForElement(WebCore::Element&amp;, WebCore::RenderStyle const&amp;)
    12  0x3d33471f0 WebCore::Style::TreeResolver::resolveElement(WebCore::Element&amp;)
    13  0x3d3348af9 WebCore::Style::TreeResolver::resolveComposedTree()
    14  0x3d33498b8 WebCore::Style::TreeResolver::resolve()
    15  0x3d1c8c77a WebCore::Document::resolveStyle(WebCore::Document::ResolveStyleType)
    16  0x3d1c8d9bd WebCore::Document::updateStyleIfNeeded()
    17  0x3d1ca5730 WebCore::Document::finishedParsing()
    18  0x3d3816fe4 WebCore::XMLDocumentParser::end()
    19  0x3d38176ea WebCore::XMLDocumentParser::resumeParsing()
    20  0x3d38174ac WebCore::XMLDocumentParser::notifyFinished(WebCore::PendingScript&amp;)
    21  0x3d1e0a307 WebCore::PendingScript::notifyClientFinished()
    22  0x3d1e0a369 WebCore::PendingScript::notifyFinished(WebCore::LoadableScript&amp;)
    23  0x3d1da8ac6 WebCore::LoadableScript::notifyClientFinished()
    24  0x3d1da88b0 WebCore::LoadableClassicScript::notifyFinished(WebCore::CachedResource&amp;)
    25  0x3d26d527f WebCore::CachedResource::checkNotify()
    26  0x3d26d0591 WebCore::CachedResource::finishLoading(WebCore::SharedBuffer*)
    27  0x3d26fe9df WebCore::CachedScript::finishLoading(WebCore::SharedBuffer*)
    28  0x3d2650971 WebCore::SubresourceLoader::didFinishLoading(WebCore::NetworkLoadMetrics const&amp;)
    29  0x3c8ddef93 WebKit::WebResourceLoader::didFinishResourceLoad(WebCore::NetworkLoadMetrics const&amp;)
    30  0x3c917c1fa void IPC::callMemberFunctionImpl&lt;WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;, 0ul&gt;(WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;&amp;&amp;, std::__1::integer_sequence&lt;unsigned long, 0ul&gt;)
    31  0x3c917bfb0 void IPC::callMemberFunction&lt;WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;), std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;, std::__1::integer_sequence&lt;unsigned long, 0ul&gt; &gt;(std::__1::tuple&lt;WebCore::NetworkLoadMetrics&gt;&amp;&amp;, WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&amp;))

    
    &gt;&gt;&gt; FontCascadeFonts::ref - 0x3ee2805a0 (3)
    1   0x3d2aa1974 WebCore::FontCascadeFonts::ref() const
    2   0x3d2aadf84 WTF::Ref&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::Ref(WebCore::FontCascadeFonts&amp;)
    3   0x3d2aabb3d WTF::Ref&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::Ref(WebCore::FontCascadeFonts&amp;)
    4   0x3d2a984a2 WebCore::retrieveOrAddCachedFonts(WebCore::FontCascadeDescription const&amp;, WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;)
    5   0x3d2a9831f WebCore::FontCascade::update(WTF::RefPtr&lt;WebCore::FontSelector, WTF::DumbPtrTraits&lt;WebCore::FontSelector&gt; &gt;&amp;&amp;) const
    6   0x3d3274f03 WebCore::RenderSVGInlineText::computeNewScaledFontForStyle(WebCore::RenderObject const&amp;, WebCore::RenderStyle const&amp;, float&amp;, WebCore::FontCascade&amp;)
    7   0x3d3273dc0 WebCore::RenderSVGInlineText::updateScaledFont()
    ..
    &gt;&gt;&gt; FontCascadeFonts::deref - 0x3ee2805a0 (2)
    1   0x3d2aa19e4 WebCore::FontCascadeFonts::deref() const
    2   0x3d228c6de void WTF::derefIfNotNull&lt;WebCore::FontCascadeFonts&gt;(WebCore::FontCascadeFonts*)
    3   0x3d228c6a9 WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::~RefPtr()
    4   0x3d228c655 WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::~RefPtr()
    5   0x3d2a97969 WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::operator=(WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt; const&amp;)
    6   0x3d2a97853 WebCore::FontCascade::operator=(WebCore::FontCascade const&amp;)
    7   0x3d3274eaf WebCore::RenderSVGInlineText::computeNewScaledFontForStyle(WebCore::RenderObject const&amp;, WebCore::RenderStyle const&amp;, float&amp;, WebCore::FontCascade&amp;)
    8   0x3d3273dc0 WebCore::RenderSVGInlineText::updateScaledFont()
    ...
    
    &gt;&gt;&gt; pruneUnreferencedEntriesFromFontCascadeCache
    &gt;&gt;&gt;     ...
    &gt;&gt;&gt;     ENTRY: 0x3ee2805a0 [2] [custom font]


In MiniBrowser the StyleResolver / FontCascade / FontCascadeFonts get destroyed as part of releaseMemory:

    static void releaseCriticalMemory(Synchronous synchronous, MaintainPageCache maintainPageCache)
    {
        ...
        for (auto&amp; document : copyToVectorOf&lt;RefPtr&lt;Document&gt;&gt;(Document::allDocuments())) {
            document-&gt;styleScope().releaseMemory();
            document-&gt;fontSelector().emptyCaches();
            document-&gt;cachedResourceLoader().garbageCollectDocumentResources();
        }
        ...
    }

    --------
    
    void Scope::clearResolver()
    {
        m_resolver = nullptr;

        if (!m_shadowRoot)
            m_document.didClearStyleResolver();
    }

    void Scope::releaseMemory()
    {
        if (!m_shadowRoot) {
            for (auto* descendantShadowRoot : m_document.inDocumentShadowRoots())
                descendantShadowRoot-&gt;styleScope().releaseMemory();
        }

    #if ENABLE(CSS_SELECTOR_JIT)
        for (auto&amp; sheet : m_activeStyleSheets) {
            sheet-&gt;contents().traverseRules([] (const StyleRuleBase&amp; rule) {
                if (is&lt;StyleRule&gt;(rule))
                    downcast&lt;StyleRule&gt;(rule).releaseCompiledSelectors();
                return false;
            });
        }
    #endif

        clearResolver();
    }

    --------

    &gt;&gt;&gt; FontCascadeFonts::deref - 0x441be1a20 (1)
    1   0x4231139e4 WebCore::FontCascadeFonts::deref() const
    2   0x4228fe6de void WTF::derefIfNotNull&lt;WebCore::FontCascadeFonts&gt;(WebCore::FontCascadeFonts*)
    3   0x4228fe6a9 WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::~RefPtr()
    4   0x4228fe655 WTF::RefPtr&lt;WebCore::FontCascadeFonts, WTF::DumbPtrTraits&lt;WebCore::FontCascadeFonts&gt; &gt;::~RefPtr()
    5   0x4228fe613 WebCore::FontCascade::~FontCascade()
    6   0x4228ecfc5 WebCore::FontCascade::~FontCascade()
    7   0x4238bb5a7 WebCore::StyleInheritedData::~StyleInheritedData()
    8   0x4238bb535 WebCore::StyleInheritedData::~StyleInheritedData()
    9   0x4238bb507 WTF::RefCounted&lt;WebCore::StyleInheritedData&gt;::deref() const
    10  0x4238bb48f WTF::Ref&lt;WebCore::StyleInheritedData, WTF::DumbPtrTraits&lt;WebCore::StyleInheritedData&gt; &gt;::~Ref()
    11  0x42389c3a5 WTF::Ref&lt;WebCore::StyleInheritedData, WTF::DumbPtrTraits&lt;WebCore::StyleInheritedData&gt; &gt;::~Ref()
    12  0x4238b2035 WebCore::DataRef&lt;WebCore::StyleInheritedData&gt;::~DataRef()
    13  0x42389c5b5 WebCore::DataRef&lt;WebCore::StyleInheritedData&gt;::~DataRef()
    14  0x42389c4fb WebCore::RenderStyle::~RenderStyle()
    15  0x42389b145 WebCore::RenderStyle::~RenderStyle()
    16  0x42219f0ab std::__1::default_delete&lt;WebCore::RenderStyle&gt;::operator()(WebCore::RenderStyle*) const
    17  0x42219f02f std::__1::unique_ptr&lt;WebCore::RenderStyle, std::__1::default_delete&lt;WebCore::RenderStyle&gt; &gt;::reset(WebCore::RenderStyle*)
    18  0x4221a9759 std::__1::unique_ptr&lt;WebCore::RenderStyle, std::__1::default_delete&lt;WebCore::RenderStyle&gt; &gt;::~unique_ptr()
    19  0x42217d055 std::__1::unique_ptr&lt;WebCore::RenderStyle, std::__1::default_delete&lt;WebCore::RenderStyle&gt; &gt;::~unique_ptr()
    20  0x4221a2e13 WebCore::StyleResolver::MatchedPropertiesCacheItem::~MatchedPropertiesCacheItem()
    21  0x42218f1a5 WebCore::StyleResolver::MatchedPropertiesCacheItem::~MatchedPropertiesCacheItem()
    22  0x42219df69 WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;::~KeyValuePair()
    23  0x42219df35 WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;::~KeyValuePair()
    24  0x42219deca WTF::HashTable&lt;unsigned int, WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;, WTF::IntHash&lt;unsigned int&gt;, WTF::HashMap&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem, WTF::IntHash&lt;unsigned int&gt;, WTF::HashTraits&lt;unsigned int&gt;, WTF::HashTraits&lt;WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;unsigned int&gt; &gt;::deallocateTable(WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;*, unsigned int)
    25  0x42219dda6 WTF::HashTable&lt;unsigned int, WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;, WTF::IntHash&lt;unsigned int&gt;, WTF::HashMap&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem, WTF::IntHash&lt;unsigned int&gt;, WTF::HashTraits&lt;unsigned int&gt;, WTF::HashTraits&lt;WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;unsigned int&gt; &gt;::~HashTable()
    26  0x42219dd65 WTF::HashTable&lt;unsigned int, WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;, WTF::IntHash&lt;unsigned int&gt;, WTF::HashMap&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem, WTF::IntHash&lt;unsigned int&gt;, WTF::HashTraits&lt;unsigned int&gt;, WTF::HashTraits&lt;WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;unsigned int&gt; &gt;::~HashTable()
    27  0x42219dd45 WTF::HashMap&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem, WTF::IntHash&lt;unsigned int&gt;, WTF::HashTraits&lt;unsigned int&gt;, WTF::HashTraits&lt;WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;::~HashMap()
    28  0x422187915 WTF::HashMap&lt;unsigned int, WebCore::StyleResolver::MatchedPropertiesCacheItem, WTF::IntHash&lt;unsigned int&gt;, WTF::HashTraits&lt;unsigned int&gt;, WTF::HashTraits&lt;WebCore::StyleResolver::MatchedPropertiesCacheItem&gt; &gt;::~HashMap()
    29  0x42218787e WebCore::StyleResolver::~StyleResolver()
    30  0x422187955 WebCore::StyleResolver::~StyleResolver()
    31  0x4239c3cbb std::__1::default_delete&lt;WebCore::StyleResolver&gt;::operator()(WebCore::StyleResolver*) const

Next up I have to check which documents releaseCriticalMemory acted on, and if the StyleResolver is getting destroyed. If they do, then understanding whats happening with a RenderStyle that didn&apos;t release the FontCascade / FontCascadeFonts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1520165</commentid>
    <comment_count>13</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-21 21:58:25 -0700</bug_when>
    <thetext>Fixing this in the bug 196059.

*** This bug has been marked as a duplicate of bug 196059 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>