<?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>91506</bug_id>
          
          <creation_ts>2012-07-17 09:05:02 -0700</creation_ts>
          <short_desc>Typo in FontCacheWin.cpp causes return value from getCachedFontData() in getLastResortFallbackFont() to be ignored</short_desc>
          <delta_ts>2012-07-20 14:27:21 -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>Platform</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 7</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Mark Salisbury">mark.salisbury</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>joepeck</cc>
    
    <cc>mark.salisbury</cc>
    
    <cc>mitz</cc>
    
    <cc>roger_fong</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>671305</commentid>
    <comment_count>0</comment_count>
      <attachid>152770</attachid>
    <who name="Mark Salisbury">mark.salisbury</who>
    <bug_when>2012-07-17 09:05:02 -0700</bug_when>
    <thetext>Created attachment 152770
Page which I used to reproduce bug

In FontCacheWin.cpp, getLastResortFallbackFont(), currently line 340, I believe there is a typo that causes the return from getCachedFontData() to be ignored.  I&apos;m a little surprised the compiler even allows this.  The problem is that the closing parenthesis is in the wrong place:

338    SimpleFontData* simpleFont;
339    for (size_t i = 0; i &lt; WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
340        if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i]), false, shouldRetain) {
341            fallbackFontName = fallbackFonts[i];
342            return simpleFont;
343        }
344    }

It should look like this:

340        if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {

There is more &apos;fallback&apos; code after this section; it checks for &quot;a DEFAULT_GUI_FONT is no known Unicode font is available&quot;.  Because of this a fallback font will be found.  It looks like this was introduced last year (http://trac.webkit.org/changeset/93140) when the shouldRetain parameter was added to getCachedFontData().

I discovered this by porting this code to Windows CE, which does not support GetStockObject(DEFAULT_GUI_FONT).  After binding out this section of code near the bottom of the function, I hit the ASSERT_NOT_REACHED.  Moving the parenthesis fixes the crash.

Steps to reproduce:
1) Load a page which does not specify a font (I attached the page I found the bug with).
2) Specify in preferences that the webkit standard font is a font which your system does not have (so that the last resort fallback code will be invoked).

Set a breakpoint in getLastResortFallbackFont().  You&apos;ll notice that even though it invokes getCachedFontData() on line 340, and the function returns a valid SimpleFontData *, the value is ignored; the code loops through all the fonts then it hits the &quot;last last&quot; resort fallback font code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>671309</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Salisbury">mark.salisbury</who>
    <bug_when>2012-07-17 09:15:54 -0700</bug_when>
    <thetext>I plan to submit a trivial patch for this, hopefully later today; it&apos;ll be a first for me.  I&apos;m working through the process right now as documented at http://www.webkit.org/coding/contributing.html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>671364</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2012-07-17 10:29:21 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; Created an attachment (id=152770) [details]
&gt; Page which I used to reproduce bug
&gt; 
&gt; In FontCacheWin.cpp, getLastResortFallbackFont(), currently line 340, I believe there is a typo that causes the return from getCachedFontData() to be ignored.  I&apos;m a little surprised the compiler even allows this.  The problem is that the closing parenthesis is in the wrong place:

Wow, great catch!

The compiler is probably fine with it because getCachedFontData has optional parameters (arg!), and this then becomes a comma expression, really only intended for the initializer section for a for loop.  Like: &quot;for (int i=0, j=0; ...)&quot;.
&lt;http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fco.htm&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>673775</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2012-07-19 12:19:40 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; I plan to submit a trivial patch for this, hopefully later today; it&apos;ll be a first for me.  I&apos;m working through the process right now as documented at http://www.webkit.org/coding/contributing.html.

It has been a few days now. Let me know if you have any questions with the contribution process.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>673783</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Salisbury">mark.salisbury</who>
    <bug_when>2012-07-19 12:28:25 -0700</bug_when>
    <thetext>Thanks Joe for following up to see where I am.

I got run-webkit-tests running against a wincairo build, then saw some fails that were unexpected so I built the standard apple &quot;release&quot; build yesterday... It&apos;s running now but TONS of tests are failing.  I expect it has nothing to do with my code change and more something being wrong in my environment.

I am still working on getting the patch.  It will be a really trivial patch, I&apos;m just trying to follow the process...

This brings up a good question though.  Do you think it&apos;s possible/reasonable to create a test for this fix?

I&apos;m not sure how we could create a test for this.  The &quot;fallback fallback&quot; code ends up creating a font, so you always get a fallback font even with this code bug.  The default font (WebCore::Settings) needs to be changed to one that&apos;s not available on the system during the testing (and I think that is possible using the internals testing object).  However, the exact font that we would then fallback to depends on user preferences (system control panel settings).  This is a very platform specific issue.  It would be easier to create a test that would show this on WinCE, since it doesn&apos;t have the final fallback code, but we don&apos;t have layout tests for WinCE at this point in time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>673829</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2012-07-19 12:55:01 -0700</bug_when>
    <thetext>(In reply to comment #4)

&gt; I am still working on getting the patch.  It will be a really trivial patch, I&apos;m just trying to follow the process...

Thanks for taking the time to do this!


&gt; This brings up a good question though.  Do you think it&apos;s possible/reasonable to create a test for this fix?

I think it would be possible, but I&apos;m not sure how reasonable it is. This was just an unfortunate typo, and the fix is straight forward. This is akin to a build fix.

Another interesting aspect of this is that we might be &quot;leaking&quot; these fonts, because the default value for getCachedFontData is to retain the font. So they are probably getting abandoned in the FontCache forever. For these kind of performance issues / improvements we normally don&apos;t require tests if they were shown to fix an issue.

And maybe this is already covered by some tests and we just have incorrect expected results for windows? You could attach a simple patch + changelog, and we can run that patch on the &quot;Early Warning System&quot; bots and see if it affects any tests. There is a Windows EWS bot.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674869</commentid>
    <comment_count>6</comment_count>
      <attachid>153573</attachid>
    <who name="Mark Salisbury">mark.salisbury</who>
    <bug_when>2012-07-20 12:48:50 -0700</bug_when>
    <thetext>Created attachment 153573
Proposed fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674951</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Salisbury">mark.salisbury</who>
    <bug_when>2012-07-20 14:10:27 -0700</bug_when>
    <thetext>I attached a patch and clicked the EWS button.  The results look good, though the few chromium EWS regressions appear flaky to me.  Any regressions should be related to fonts/pixel diffs/layout size, not HTTP failures/tests timing out.

I&apos;m just waiting for a reviewer to take a look now.

Chromium DRT fails:

  http/tests/cache/post-redirect-get.php -&gt; unexpected no expected result found
  http/tests/cache/post-with-cached-subresources.php -&gt; unexpected no expected result found
  editing/spelling/grammar-markers.html -&gt; pixel hash failed (but pixel test still passes)
  fast/events/dispatch-message-string-data.html -&gt; unexpected test timed out
  fast/forms/range/slider-delete-while-dragging-thumb.html -&gt; unexpected text diff mismatch
  fast/forms/range/slider-mouse-events.html -&gt; unexpected text diff mismatch
  fast/forms/range/slider-onchange-event.html -&gt; unexpected text diff mismatch
  fast/frames/cached-frame-counter.html -&gt; unexpected test timed out
  http/tests/security/script-crossorigin-loads-correctly.html -&gt; unexpected text diff mismatch
  fast/loader/loadInProgress.html -&gt; unexpected text diff mismatch
  fast/loader/unload-form-post-about-blank.html -&gt; unexpected test timed out
  http/tests/xmlhttprequest/zero-length-response.html -&gt; unexpected test timed out
  svg/batik/text/smallFonts.svg -&gt; unexpected image mismatch
  svg/batik/text/textLayout2.svg -&gt; unexpected iFailed to run &quot;[&apos;xvfb-run&apos;, &apos;Tools/Scripts/new-run-webkit-tests&apos;, &apos;--chromium&apos;, &apos;--skip-failing-tests&apos;, &apos;--no-ne...&quot; exit_code: 3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674955</commentid>
    <comment_count>8</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2012-07-20 14:11:43 -0700</bug_when>
    <thetext>The Chromium EWS comments in the bug if there are failures; it looks green above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674963</commentid>
    <comment_count>9</comment_count>
      <attachid>153573</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2012-07-20 14:16:29 -0700</bug_when>
    <thetext>Comment on attachment 153573
Proposed fix

r=me. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674973</commentid>
    <comment_count>10</comment_count>
      <attachid>153573</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-07-20 14:27:16 -0700</bug_when>
    <thetext>Comment on attachment 153573
Proposed fix

Clearing flags on attachment: 153573

Committed r123262: &lt;http://trac.webkit.org/changeset/123262&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>674974</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-07-20 14:27:21 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>152770</attachid>
            <date>2012-07-17 09:05:02 -0700</date>
            <delta_ts>2012-07-17 09:05:02 -0700</delta_ts>
            <desc>Page which I used to reproduce bug</desc>
            <filename>date-time-test.html</filename>
            <type>text/html</type>
            <size>340</size>
            <attacher name="Mark Salisbury">mark.salisbury</attacher>
            
              <data encoding="base64">PHNjcmlwdD4NCg0KdmFyIHRvZGF5ID0gbmV3IERhdGUoKQ0KdmFyIGQxID0gbmV3IERhdGUoIk9j
dG9iZXIgMTMsIDE5NzUgMTE6MTM6MDAiKTsNCnZhciBkMiA9IG5ldyBEYXRlKDc5LDUsMjQpOw0K
dmFyIGQzID0gbmV3IERhdGUoNzksNSwyNCwxMSwzMywwKTsNCg0KDQpkb2N1bWVudC53cml0ZSgi
PGRpdj5kMSA9ICIgKyBkMS50b1N0cmluZygpICsgIjwvZGl2PiIpOw0KZG9jdW1lbnQud3JpdGUo
IjxkaXY+ZDIgPSAiICsgZDIudG9TdHJpbmcoKSArICI8L2Rpdj4iKTsNCmRvY3VtZW50LndyaXRl
KCI8ZGl2PmQzID0gIiArIGQzLnRvU3RyaW5nKCkgKyAiPC9kaXY+Iik7DQoNCjwvc2NyaXB0Pg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>153573</attachid>
            <date>2012-07-20 12:48:50 -0700</date>
            <delta_ts>2012-07-20 14:27:16 -0700</delta_ts>
            <desc>Proposed fix</desc>
            <filename>Patch-91506.patch</filename>
            <type>text/plain</type>
            <size>1736</size>
            <attacher name="Mark Salisbury">mark.salisbury</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZw0KPT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLS0tIFNvdXJjZS9X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o=
</data>

          </attachment>
      

    </bug>

</bugzilla>