Changeset 243483 in webkit
- Timestamp:
- Mar 25, 2019, 8:34:43 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
css/CSSFontFaceSource.cpp (modified) (5 diffs)
-
css/CSSFontFaceSource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243482 r243483 1 2019-03-20 Ryosuke Niwa <rniwa@webkit.org> 2 3 Leak of SVGFontFaceElement when RenderStyle holds onto a FontRances which uses it 4 https://bugs.webkit.org/show_bug.cgi?id=196059 5 6 Reviewed by Zalan Bujtas. 7 8 SVGFontFaceElement keeps its RenderStyle alive via ElementRareData but RenderStyle can hold onto FontRanges 9 and therefore CSSFontSource, which in turn keeps SVGFontFaceElement alive, making a reference cycle. 10 11 More precisely, there are two reference cycles: 12 SVGFontFaceElement (1) -> ElementRareData -> StyleInheritedData -> FontCascade -> FontCascadeFonts (2) 13 FontCascadeFonts (2) -> FontRanges (3) 14 FontCascadeFonts (2) -> CSSFontSelector -> CSSFontFaceSet -> CSSSegmentedFontFace -> FontRanges (3) 15 FontRanges (3) -> CSSFontAccessor > CSSFontFace > CSSFontSource -> SVGFontFaceElement (1) 16 17 No new tests. Unfortunately, writing a test proved to be intractable. The leak can be reproduced by running 18 svg/text/text-text-05-t.svg then svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html consecutively. 19 20 * css/CSSFontFaceSource.cpp: 21 (WebCore::CSSFontFaceSource::CSSFontFaceSource): 22 (WebCore::CSSFontFaceSource::load): 23 (WebCore::CSSFontFaceSource::font): 24 (WebCore::CSSFontFaceSource::isSVGFontFaceSource const): 25 * css/CSSFontFaceSource.h: 26 1 27 2019-03-25 Fujii Hironori <Hironori.Fujii@sony.com> 2 28 -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r239535 r243483 80 80 , m_immediateSource(WTFMove(arrayBufferView)) 81 81 #if ENABLE(SVG_FONTS) 82 , m_svgFontFaceElement(fontFace) 82 , m_svgFontFaceElement(makeWeakPtr(fontFace)) 83 , m_hasSVGFontFaceElement(m_svgFontFaceElement) 83 84 #endif 84 85 { … … 155 156 bool success = false; 156 157 #if ENABLE(SVG_FONTS) 157 if (m_ svgFontFaceElement) {158 if ( is<SVGFontElement>(m_svgFontFaceElement->parentNode())) {158 if (m_hasSVGFontFaceElement) { 159 if (m_svgFontFaceElement && is<SVGFontElement>(m_svgFontFaceElement->parentNode())) { 159 160 ASSERT(!m_inDocumentCustomPlatformData); 160 161 SVGFontElement& fontElement = downcast<SVGFontElement>(*m_svgFontFaceElement->parentNode()); … … 196 197 ASSERT(status() == Status::Success); 197 198 198 SVGFontFaceElement* fontFaceElement = nullptr; 199 #if ENABLE(SVG_FONTS) 200 fontFaceElement = m_svgFontFaceElement.get(); 201 #endif 202 203 if (!m_font && !fontFaceElement) { 199 #if ENABLE(SVG_FONTS) 200 bool usesInDocumentSVGFont = m_hasSVGFontFaceElement; 201 #endif 202 203 if (!m_font && !usesInDocumentSVGFont) { 204 204 if (m_immediateSource) { 205 205 if (!m_immediateFontCustomPlatformData) … … 223 223 } 224 224 225 // In-Document SVG Fonts 226 if (!fontFaceElement) 225 if (!usesInDocumentSVGFont) 227 226 return nullptr; 228 227 229 228 #if ENABLE(SVG_FONTS) 230 if (! is<SVGFontElement>(m_svgFontFaceElement->parentNode()))229 if (!m_svgFontFaceElement || !is<SVGFontElement>(m_svgFontFaceElement->parentNode())) 231 230 return nullptr; 232 231 if (!m_inDocumentCustomPlatformData) … … 242 241 bool CSSFontFaceSource::isSVGFontFaceSource() const 243 242 { 244 return m_ svgFontFaceElement || is<CachedSVGFont>(m_font.get());245 } 246 #endif 247 248 } 243 return m_hasSVGFontFaceElement || is<CachedSVGFont>(m_font.get()); 244 } 245 #endif 246 247 } -
trunk/Source/WebCore/css/CSSFontFaceSource.h
r228218 r243483 94 94 95 95 #if ENABLE(SVG_FONTS) 96 RefPtr<SVGFontFaceElement> m_svgFontFaceElement;96 WeakPtr<SVGFontFaceElement> m_svgFontFaceElement; 97 97 #endif 98 98 std::unique_ptr<FontCustomPlatformData> m_inDocumentCustomPlatformData; 99 99 100 100 Status m_status { Status::Pending }; 101 #if ENABLE(SVG_FONTS) 102 bool m_hasSVGFontFaceElement; 103 #endif 101 104 }; 102 105
Note:
See TracChangeset
for help on using the changeset viewer.