Title: [235862] trunk/Source/WebCore
Revision
235862
Author
[email protected]
Date
2018-09-10 14:19:49 -0700 (Mon, 10 Sep 2018)

Log Message

svg/W3C-SVG-1.1/render-groups-03-t.svg and some other SVG tests leak documents
https://bugs.webkit.org/show_bug.cgi?id=189147

Reviewed by Dean Jackson.

Document::removedLastRef() needs to clean up m_fontSelector, because it can reference
CSSFontFaceSources that keep SVGFontFaceElements alive, and they in turn will keep
the Document alive.

Also add the beginnings of a Fonts log channel.

This will be tested by world leak testing (webkit.org/b/189332).

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::CSSFontSelector):
(WebCore::CSSFontSelector::~CSSFontSelector):
* dom/Document.cpp:
(WebCore::Document::removedLastRef):
* platform/Logging.h:
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::purgeInactiveFontDataIfNeeded):
(WebCore::FontCache::purgeInactiveFontData):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::SVGFontFaceElement):
(WebCore::SVGFontFaceElement::~SVGFontFaceElement):
* svg/SVGFontFaceElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235861 => 235862)


--- trunk/Source/WebCore/ChangeLog	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/ChangeLog	2018-09-10 21:19:49 UTC (rev 235862)
@@ -1,3 +1,32 @@
+2018-09-10  Simon Fraser  <[email protected]>
+
+        svg/W3C-SVG-1.1/render-groups-03-t.svg and some other SVG tests leak documents
+        https://bugs.webkit.org/show_bug.cgi?id=189147
+
+        Reviewed by Dean Jackson.
+        
+        Document::removedLastRef() needs to clean up m_fontSelector, because it can reference
+        CSSFontFaceSources that keep SVGFontFaceElements alive, and they in turn will keep
+        the Document alive.
+        
+        Also add the beginnings of a Fonts log channel.
+
+        This will be tested by world leak testing (webkit.org/b/189332).
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::CSSFontSelector):
+        (WebCore::CSSFontSelector::~CSSFontSelector):
+        * dom/Document.cpp:
+        (WebCore::Document::removedLastRef):
+        * platform/Logging.h:
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontCache::purgeInactiveFontDataIfNeeded):
+        (WebCore::FontCache::purgeInactiveFontData):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+        (WebCore::SVGFontFaceElement::~SVGFontFaceElement):
+        * svg/SVGFontFaceElement.h:
+
 2018-09-10  Don Olmstead  <[email protected]>
 
         CBOR coders should only be compiled if WebAuthN is enabled

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (235861 => 235862)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2018-09-10 21:19:49 UTC (rev 235862)
@@ -45,6 +45,7 @@
 #include "FontSelectorClient.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "Logging.h"
 #include "Settings.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
@@ -68,10 +69,13 @@
     ASSERT(m_document);
     FontCache::singleton().addClient(*this);
     m_cssFontFaceSet->addClient(*this);
+    LOG(Fonts, "CSSFontSelector %p ctor", this);
 }
 
 CSSFontSelector::~CSSFontSelector()
 {
+    LOG(Fonts, "CSSFontSelector %p dtor", this);
+
     clearDocument();
     m_cssFontFaceSet->removeClient(*this);
     FontCache::singleton().removeClient(*this);

Modified: trunk/Source/WebCore/dom/Document.cpp (235861 => 235862)


--- trunk/Source/WebCore/dom/Document.cpp	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-09-10 21:19:49 UTC (rev 235862)
@@ -684,6 +684,9 @@
 #endif
         m_associatedFormControls.clear();
 
+        m_fontSelector->clearDocument();
+        m_fontSelector->unregisterForInvalidationCallbacks(*this);
+
         detachParser();
 
         // removeDetachedChildren() doesn't always unregister IDs,

Modified: trunk/Source/WebCore/platform/Logging.h (235861 => 235862)


--- trunk/Source/WebCore/platform/Logging.h	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/platform/Logging.h	2018-09-10 21:19:49 UTC (rev 235862)
@@ -49,6 +49,7 @@
     M(Events) \
     M(FileAPI) \
     M(Filters) \
+    M(Fonts) \
     M(Frames) \
     M(FTP) \
     M(Fullscreen) \

Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (235861 => 235862)


--- trunk/Source/WebCore/platform/graphics/FontCache.cpp	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp	2018-09-10 21:19:49 UTC (rev 235862)
@@ -33,6 +33,7 @@
 #include "FontCascade.h"
 #include "FontPlatformData.h"
 #include "FontSelector.h"
+#include "Logging.h"
 #include "WebKitFontFamilyNames.h"
 #include <wtf/HashMap.h>
 #include <wtf/MemoryPressureHandler.h>
@@ -350,6 +351,8 @@
     bool underMemoryPressure = MemoryPressureHandler::singleton().isUnderMemoryPressure();
     unsigned inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData;
 
+    LOG(Fonts, "FontCache::purgeInactiveFontDataIfNeeded() - underMemoryPressure %d, inactiveFontDataLimit %u", underMemoryPressure, inactiveFontDataLimit);
+
     if (cachedFonts().size() < inactiveFontDataLimit)
         return;
     unsigned inactiveCount = inactiveFontCount();
@@ -362,6 +365,8 @@
 
 void FontCache::purgeInactiveFontData(unsigned purgeCount)
 {
+    LOG(Fonts, "FontCache::purgeInactiveFontData(%u)", purgeCount);
+
     pruneUnreferencedEntriesFromFontCascadeCache();
     pruneSystemFallbackFonts();
 
@@ -372,6 +377,7 @@
     while (purgeCount) {
         Vector<RefPtr<Font>, 20> fontsToDelete;
         for (auto& font : cachedFonts().values()) {
+            LOG(Fonts, " trying to purge font %s (has one ref %d)", font->platformData().description().utf8().data(), font->hasOneRef());
             if (!font->hasOneRef())
                 continue;
             fontsToDelete.append(WTFMove(font));
@@ -396,6 +402,9 @@
         if (entry.value && !cachedFonts().contains(*entry.value))
             keysToRemove.uncheckedAppend(entry.key);
     }
+
+    LOG(Fonts, " removing %lu keys", keysToRemove.size());
+
     for (auto& key : keysToRemove)
         fontPlatformDataCache().remove(key);
 

Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (235861 => 235862)


--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2018-09-10 21:19:49 UTC (rev 235862)
@@ -33,6 +33,7 @@
 #include "Document.h"
 #include "ElementIterator.h"
 #include "FontCascade.h"
+#include "Logging.h"
 #include "SVGDocumentExtensions.h"
 #include "SVGFontElement.h"
 #include "SVGFontFaceSrcElement.h"
@@ -56,9 +57,15 @@
     , m_fontFaceRule(StyleRuleFontFace::create(MutableStyleProperties::create(HTMLStandardMode)))
     , m_fontElement(nullptr)
 {
+    LOG(Fonts, "SVGFontFaceElement %p ctor", this);
     ASSERT(hasTagName(font_faceTag));
 }
 
+SVGFontFaceElement::~SVGFontFaceElement()
+{
+    LOG(Fonts, "SVGFontFaceElement %p dtor", this);
+}
+
 Ref<SVGFontFaceElement> SVGFontFaceElement::create(const QualifiedName& tagName, Document& document)
 {
     return adoptRef(*new SVGFontFaceElement(tagName, document));

Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.h (235861 => 235862)


--- trunk/Source/WebCore/svg/SVGFontFaceElement.h	2018-09-10 21:11:23 UTC (rev 235861)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.h	2018-09-10 21:19:49 UTC (rev 235862)
@@ -55,6 +55,7 @@
 
 private:
     SVGFontFaceElement(const QualifiedName&, Document&);
+    ~SVGFontFaceElement();
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to