<?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>151261</bug_id>
          
          <creation_ts>2015-11-13 07:07:21 -0800</creation_ts>
          <short_desc>[GTK] ImageDiff should normalize the diff image</short_desc>
          <delta_ts>2015-11-22 00:54:11 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=85299</see_also>
          <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>1</everconfirmed>
          <reporter name="Carlos Alberto Lopez Perez">clopez</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>lforschler</cc>
    
    <cc>svillar</cc>
    
    <cc>zan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1141831</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-11-13 07:07:21 -0800</bug_when>
    <thetext>I was checking the diff image for the following ref test that is failing by 1-pixel test:

https://build.webkit.org/results/GTK%20Linux%2064-bit%20Release%20%28Tests%29/r192415%20%2812243%29/imported/blink/fast/canvas/canvas-clip-stack-persistence-diffs.html

As you can check, on the diff image is hard to see what is different (everything looks black).

So I tried to manually to create a diff image using imagemagick as follows:

$ wget https://build.webkit.org/results/GTK%20Linux%2064-bit%20Release%20%28Tests%29/r192415%20%2812243%29/imported/blink/fast/canvas/canvas-clip-stack-persistence-actual.png
$ wget https://build.webkit.org/results/GTK%20Linux%2064-bit%20Release%20%28Tests%29/r192415%20%2812243%29/imported/blink/fast/canvas/canvas-clip-stack-persistence-expected.png
$ composite canvas-clip-stack-persistence-expected.png canvas-clip-stack-persistence-actual.png -compose difference diff.png

The diff.png image generated was like the current we produce. Hard to tell if there is any difference or where.

The I normalized the diff image as follows:

$ convert diff.png -auto-level diff_norm.png

Now the diff_norm.png shows clearly where the problem is.

So I think we can teach ImageDiff to auto normalize the diff image.

I see that each ports seems to have its own version of ImageDiff.

I only tested the GTK one, and opening the bug for this one.

A quick grep suggests that other ports are already normalizing the diff image:
$ find Tools/ -type f -iname &quot;imagediff*.*cpp&quot;|xargs grep -i normalize</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1141874</commentid>
    <comment_count>1</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-11-13 10:42:37 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; The I normalized the diff image as follows:
&gt; 
&gt; $ convert diff.png -auto-level diff_norm.png
&gt; 
&gt; Now the diff_norm.png shows clearly where the problem is.
&gt; 

This is the result: http://people.igalia.com/clopez/wkbug/151261/canvas-clip-stack-persistence-diff_normalized.png</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1142495</commentid>
    <comment_count>2</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2015-11-17 01:12:54 -0800</bug_when>
    <thetext>We should definitely do that! There are a lot of 1-pixel diff test cases that fail from time to time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1143239</commentid>
    <comment_count>3</comment_count>
      <attachid>265855</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-11-19 01:25:14 -0800</bug_when>
    <thetext>Created attachment 265855
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1143617</commentid>
    <comment_count>4</comment_count>
      <attachid>265855</attachid>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2015-11-20 03:20:01 -0800</bug_when>
    <thetext>Comment on attachment 265855
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=265855&amp;action=review

Can&apos;t we immediately unskip a bunch of tests?

&gt; Tools/ImageDiff/gtk/ImageDiff.cpp:85
&gt; +                bufferPixel /= maxDistance;

What guarantees that maxDistance is not 0?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1143618</commentid>
    <comment_count>5</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-11-20 03:28:04 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; Comment on attachment 265855 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=265855&amp;action=review
&gt; 
&gt; Can&apos;t we immediately unskip a bunch of tests?

No, this doesn&apos;t fix any test, this only makes it easier to see the differences when they are minimum, see the examples Carlos posted here, without the patch you see a diff that looks completely black, while after the patch you easily see the pixel that is different. 

&gt; &gt; Tools/ImageDiff/gtk/ImageDiff.cpp:85
&gt; &gt; +                bufferPixel /= maxDistance;
&gt; 
&gt; What guarantees that maxDistance is not 0?

I think differenceImageFromDifferenceBuffer wouldn&apos;t be called in that case, I could ensure it just in case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1144011</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-11-22 00:54:11 -0800</bug_when>
    <thetext>Committed r192728: &lt;http://trac.webkit.org/changeset/192728&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>265855</attachid>
            <date>2015-11-19 01:25:14 -0800</date>
            <delta_ts>2015-11-20 03:20:01 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>wk-image-diff-normalize.diff</filename>
            <type>text/plain</type>
            <size>2691</size>
            <attacher name="Carlos Garcia Campos">cgarcia</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1Rvb2xzL0NoYW5nZUxvZyBiL1Rvb2xzL0NoYW5nZUxvZwppbmRleCBiZDA5
YmE2Li4zNTEyYTdiIDEwMDY0NAotLS0gYS9Ub29scy9DaGFuZ2VMb2cKKysrIGIvVG9vbHMvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTUgQEAKKzIwMTUtMTEtMTkgIENhcmxvcyBHYXJjaWEgQ2FtcG9z
ICA8Y2dhcmNpYUBpZ2FsaWEuY29tPgorCisgICAgICAgIFtHVEtdIEltYWdlRGlmZiBzaG91bGQg
bm9ybWFsaXplIHRoZSBkaWZmIGltYWdlCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3Jn
L3Nob3dfYnVnLmNnaT9pZD0xNTEyNjEKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9P
UFMhKS4KKworICAgICAgICAqIEltYWdlRGlmZi9ndGsvSW1hZ2VEaWZmLmNwcDoKKyAgICAgICAg
KHJlYWRQaXhidWZGcm9tU3RkaW4pOiBGaXggbWVtb3J5IGxlYWsuCisgICAgICAgIChkaWZmZXJl
bmNlSW1hZ2VGcm9tRGlmZmVyZW5jZUJ1ZmZlcik6IE5vcm1hbGl6ZSBkaWZmIGJ1ZmZlci4KKyAg
ICAgICAgKGNhbGN1bGF0ZURpZmZlcmVuY2UpOiBQYXNzIG1heCBkaXN0YW5jZSB0byBkaWZmZXJl
bmNlSW1hZ2VGcm9tRGlmZmVyZW5jZUJ1ZmZlci4KKwogMjAxNS0xMS0xOSAgWW91ZW5uIEZhYmxl
dCAgPHlvdWVubi5mYWJsZXRAY3JmLmNhbm9uLmZyPgogCiAgICAgICAgIFdQVCBzZXJ2ZXIgc2hv
dWxkIHVzZSBpdHMgb3duIHRlc3RoYXJuZXNzLmpzIG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4YnVmKiBhY3R1YWxJbWFnZSwgR2RrUAogICAgIGVsc2UgewogICAgICAgICBk
aWZmZXJlbmNlID0gcm91bmRmKGRpZmZlcmVuY2UgKiAxMDAuMGYpIC8gMTAwLjBmOwogICAgICAg
ICBkaWZmZXJlbmNlID0gbWF4KGRpZmZlcmVuY2UsIDAuMDFmKTsgLy8gcm91bmQgdG8gMiBkZWNp
bWFsIHBsYWNlcwotICAgICAgICAqZGlmZmVyZW5jZUltYWdlID0gZGlmZmVyZW5jZUltYWdlRnJv
bURpZmZlcmVuY2VCdWZmZXIoZGlmZkJ1ZmZlciwgd2lkdGgsIGhlaWdodCk7CisgICAgICAgICpk
aWZmZXJlbmNlSW1hZ2UgPSBkaWZmZXJlbmNlSW1hZ2VGcm9tRGlmZmVyZW5jZUJ1ZmZlcihkaWZm
QnVmZmVyLCB3aWR0aCwgaGVpZ2h0LCBtYXhEaXN0YW5jZSk7CiAgICAgfQogCiAgICAgZnJlZShk
aWZmQnVmZmVyKTsK
</data>
<flag name="review"
          id="290870"
          type_id="1"
          status="+"
          setter="svillar"
    />
          </attachment>
      

    </bug>

</bugzilla>