<?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>14601</bug_id>
          
          <creation_ts>2007-07-13 03:35:27 -0700</creation_ts>
          <short_desc>WebCore/Windows: too many FontData object and takes too much memory</short_desc>
          <delta_ts>2007-07-19 14:21:20 -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>WebCore Misc.</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar, PlatformOnly</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>808caaa4.8ce9.9cd6c799e9f6</reporter>
          <assigned_to name="Dave Hyatt">hyatt</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4910</commentid>
    <comment_count>0</comment_count>
    <who name="">808caaa4.8ce9.9cd6c799e9f6</who>
    <bug_when>2007-07-13 03:35:27 -0700</bug_when>
    <thetext>In WebCore::FontCache::getFontDataForCharacters(),
many many FontData/FontPlatformData objects created with same constructor parameters.

HFONT by IMLangFontLink2 is cached result(documented in MSDN docs).
FontPlatformData objects have CFFont object, work buffer, for each.

FontData/FontPlatformData objects live as long as the process lives.
Another saying, objects isn&apos;t destroyed even after closing assosiated views.


Example: viewing news.google.co.jp, with caching FontData objects like this:

-------------------------
.../WebCore/platform/win/FontCacheWin.cpp
-------------------------
fontData = new FontData(FontPlatformData(result, font.fontDescription().computedPixelSize(), font.fontDescription().bold(), font.fontDescription().italic()));
-&gt;
fontData = CreateFontDataWithCache(result, font.fontDescription().computedPixelSize(), font.fontDescription().bold(), font.fontDescription().italic());
-------------------------

Results: only 8 objects created, and almost 1400 objects avoided from creation,
30MB memory seems to be saved (71MB used without cache, 40MB used with cache.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4759</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-07-14 15:19:29 -0700</bug_when>
    <thetext>&lt;rdar://problem/5335829&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4571</commentid>
    <comment_count>2</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-16 13:08:38 -0700</bug_when>
    <thetext>I think this should be P1.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4573</commentid>
    <comment_count>3</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-16 13:15:17 -0700</bug_when>
    <thetext>Actually lowering this back to P2.  This case should only get hit if no font specified in CSS contains the right characters.  I&apos;m not completely sure how we would go about caching this result, since the value returned is dependent on the characters being used.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4574</commentid>
    <comment_count>4</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-16 13:16:48 -0700</bug_when>
    <thetext>Oh, never mind, I get it.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4576</commentid>
    <comment_count>5</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-16 13:22:19 -0700</bug_when>
    <thetext>This is definitely a P1 issue.  Mac is actually using the cache for this method, but Windows is creating a new FontData every time.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4579</commentid>
    <comment_count>6</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-16 13:48:43 -0700</bug_when>
    <thetext>My assumption was that mlang would give me different HFONTs, but if it really does cache fonts internally, then we can simply use our cache on top of mlang.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4554</commentid>
    <comment_count>7</comment_count>
    <who name="">808caaa4.8ce9.9cd6c799e9f6</who>
    <bug_when>2007-07-17 02:38:08 -0700</bug_when>
    <thetext>errata: not CFFont, is CGFont, of course.

http://msdn2.microsoft.com/En-US/library/aa741043.aspx
&gt; IMLangFontLink does (font linking) by creating custom fonts and 
&gt; providing an underlying font cache in the implementation.

Actually same (DWORD)HFONT returns many times, and
number of GDI objects NOT SO increased.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4538</commentid>
    <comment_count>8</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-07-17 07:10:58 -0700</bug_when>
    <thetext>Fixed in r24332.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4375</commentid>
    <comment_count>9</comment_count>
    <who name="">808caaa4.8ce9.9cd6c799e9f6</who>
    <bug_when>2007-07-18 18:32:49 -0700</bug_when>
    <thetext>new impl: beautiful.

-----
FontPlatformData platformData(result, ...);
fontData = getCachedFontData(&amp;platformData);
fontData-&gt;setIsMLangFont();
-----

I fear if this temporary platformData&apos;s associated objects is successfully deleted....
(Of cource, platformData itself is on local stack.)

-----
FontPlatformData::~FontPlatformData()
{
}
-----

In FE environment this constructor is called for almost every every every FE chars.
Constructor checks and fills for m_synthetic***s with calling 
GetOutlineTextMetricsW(),EnumFontFamiliesEx() each time, and creates CGFont inside.

Checking before creating FontPlatformData objects is with reality, 
rather than implementing destructors or delay-CGFont-creation, I thought.


Additional info. (might be another issue but related)
IMLangFontLink certainly caches our HFONTs, but it&apos;s cache slot might be too small?
langFontLink-&gt;MapFont() seems returns E_INVALID so often with correct arguments... why?
I&apos;m working now for verification about this hypnosis.
If proofed, I&apos;ll report here and ask for instructions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4265</commentid>
    <comment_count>10</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-07-19 14:21:20 -0700</bug_when>
    <thetext>There is an underlying CGFontRef cache, so we are not creating new CGFontRefs every time.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>