<?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>85292</bug_id>
          
          <creation_ts>2012-05-01 09:32:39 -0700</creation_ts>
          <short_desc>ImageDiff should be run inside a properly established environment</short_desc>
          <delta_ts>2012-05-03 05:12:35 -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>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>1</everconfirmed>
          <reporter name="Zan Dobersek">zan</reporter>
          <assigned_to name="Zan Dobersek">zan</assigned_to>
          <cc>abarth</cc>
    
    <cc>dpranke</cc>
    
    <cc>mrobinson</cc>
    
    <cc>ojan</cc>
    
    <cc>pnormand</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>613463</commentid>
    <comment_count>0</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 09:32:39 -0700</bug_when>
    <thetext>As with DumpRenderTree, WebKitTestRunner and even http and websocket servers, ImageDiff should be ran inside an environment that was created with port.setup_environment_for_server() function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613467</commentid>
    <comment_count>1</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 09:35:23 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; As with DumpRenderTree, WebKitTestRunner and even http and websocket servers, ImageDiff should be ran inside an environment that was created with port.setup_environment_for_server() function.

Specifically for the Gtk port, the lack of doing this resulted in ImageDiff crashing because it was not being able to open the display.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613469</commentid>
    <comment_count>2</comment_count>
      <attachid>139640</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 09:37:32 -0700</bug_when>
    <thetext>Created attachment 139640
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613482</commentid>
    <comment_count>3</comment_count>
      <attachid>139640</attachid>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2012-05-01 09:45:53 -0700</bug_when>
    <thetext>Comment on attachment 139640
Patch

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

This approach makes sense to me, however:

&gt; Tools/Scripts/webkitpy/layout_tests/port/webkit.py:183
&gt; +        environment = self._port.setup_environ_for_server(&apos;ImageDiff&apos;)

I&apos;m afraid this doesn&apos;t set the DISPLAY env var in GTK :( It&apos;s set only in the GtkDriver._start method or did I miss something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613496</commentid>
    <comment_count>4</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 10:12:57 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 139640 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=139640&amp;action=review
&gt; 
&gt; This approach makes sense to me, however:
&gt; 
&gt; &gt; Tools/Scripts/webkitpy/layout_tests/port/webkit.py:183
&gt; &gt; +        environment = self._port.setup_environ_for_server(&apos;ImageDiff&apos;)
&gt; 
&gt; I&apos;m afraid this doesn&apos;t set the DISPLAY env var in GTK :( It&apos;s set only in the GtkDriver._start method or did I miss something?

It uses the display in which new-run-webkit-tests is run. This is done for all the ports in base.py[1]. In the case of the Gtk bots, I can see both 64-bit bots having a DISPLAY env of value &apos;:10&apos;, while the 32-bit bot doesn&apos;t have that env set (which might cause problems).

In GtkDriver, a new display is spawn for each driver starting, with none of these drivers being connected to the WebKitPort object, so it might be difficult to get a proper display number.

Also, I just realized the patch is wrong - setup_environ_for_server should be called on self, not self._port.

[1] http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py#L759</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613499</commentid>
    <comment_count>5</comment_count>
      <attachid>139647</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 10:17:31 -0700</bug_when>
    <thetext>Created attachment 139647
Patch

Fixed patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613509</commentid>
    <comment_count>6</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2012-05-01 10:33:55 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; (From update of attachment 139640 [details] [details])
&gt; &gt; View in context: https://bugs.webkit.org/attachment.cgi?id=139640&amp;action=review
&gt; &gt; 
&gt; &gt; This approach makes sense to me, however:
&gt; &gt; 
&gt; &gt; &gt; Tools/Scripts/webkitpy/layout_tests/port/webkit.py:183
&gt; &gt; &gt; +        environment = self._port.setup_environ_for_server(&apos;ImageDiff&apos;)
&gt; &gt; 
&gt; &gt; I&apos;m afraid this doesn&apos;t set the DISPLAY env var in GTK :( It&apos;s set only in the GtkDriver._start method or did I miss something?
&gt; 
&gt; It uses the display in which new-run-webkit-tests is run. This is done for all the ports in base.py[1]. In the case of the Gtk bots, I can see both 64-bit bots having a DISPLAY env of value &apos;:10&apos;, while the 32-bit bot doesn&apos;t have that env set (which might cause problems).
&gt; 

They shouldn&apos;t have a pre-configured DISPLAY, I think.
What about spawning a new xvfb process if needed by ImageDiff? The :1 value used in base.py looks hasardous, how are we sure a X server is running on :1 ?

&gt; In GtkDriver, a new display is spawn for each driver starting, with none of these drivers being connected to the WebKitPort object, so it might be difficult to get a proper display number.
&gt; 

Maybe that code can be refactored then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>613555</commentid>
    <comment_count>7</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2012-05-01 11:32:32 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; (In reply to comment #0)
&gt; &gt; As with DumpRenderTree, WebKitTestRunner and even http and websocket servers, ImageDiff should be ran inside an environment that was created with port.setup_environment_for_server() function.
&gt; 
&gt; Specifically for the Gtk port, the lack of doing this resulted in ImageDiff crashing because it was not being able to open the display.

Hrm. ImageDiff should probably be rewritten such that it doesn&apos;t need an X11 display.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>614015</commentid>
    <comment_count>8</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-01 23:14:34 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #1)
&gt; &gt; (In reply to comment #0)
&gt; &gt; &gt; As with DumpRenderTree, WebKitTestRunner and even http and websocket servers, ImageDiff should be ran inside an environment that was created with port.setup_environment_for_server() function.
&gt; &gt; 
&gt; &gt; Specifically for the Gtk port, the lack of doing this resulted in ImageDiff crashing because it was not being able to open the display.
&gt; 
&gt; Hrm. ImageDiff should probably be rewritten such that it doesn&apos;t need an X11 display.

While I find the current implementation with the GdkPixbufLoader extremely elegant, I guess the alternative would be to use Cairo (and possibly share most of the code with the Win port).

Another possibility is to rewrite the ImageDiff tool in Python, making it platform-independent. Looking across current ImageDiff implementations, only Chromium&apos;s differs a bit in functionality, while basically all are using the same difference algorithm.

While it would be nice to unify the behavior in a cross-platform implementation, I don&apos;t think this would be that simple without introducing another python dependency on a specific imaging library. While the diff algorithm is basically the same in every current implementation, the PNG data is still gathered in a platform-dependent way, making that data possibly vary in the format of row strides, alpha channels etc, making way to problems.

As a current workaround, I&apos;ve modified the GtkDriver to contain a static list of open displays, with GtkPort, when setting up environment for ImageDiff, choosing the latest opened display (an open display should always be available when running ImageDiff). But it&apos;s just a work-in-progress workaround that&apos;s to be abandoned if we can soon get to a consensus on what&apos;s to be done.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>614383</commentid>
    <comment_count>9</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2012-05-02 09:54:46 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; Another possibility is to rewrite the ImageDiff tool in Python, making it platform-independent. Looking across current ImageDiff implementations, only Chromium&apos;s differs a bit in functionality, while basically all are using the same difference algorithm.

Historically, the concern with a python implementation is performance. Having this code be platform-independent would obviously be great. If someone puts together a python implementation and shows that it has negligible impact on the time it takes to run the full test suite, then I think everyone would be happier with that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>614600</commentid>
    <comment_count>10</comment_count>
    <who name="Dirk Pranke">dpranke</who>
    <bug_when>2012-05-02 13:26:45 -0700</bug_when>
    <thetext>I&apos;ve been playing around with pure-python PNG logic, and the best I&apos;ve found seems to be buggy so far (at least for computing the checksums), and is definitely slower (but I don&apos;t know how significant the impact is yet). See bug 68039 for more on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>614602</commentid>
    <comment_count>11</comment_count>
    <who name="Dirk Pranke">dpranke</who>
    <bug_when>2012-05-02 13:27:40 -0700</bug_when>
    <thetext>Also, for the record, this change looks fine to me but I&apos;ll let mrobinson or pnormand give the final blessing if they like.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>615169</commentid>
    <comment_count>12</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-03 05:06:06 -0700</bug_when>
    <thetext>Thanks for the review.

It so happens that after a bit more looking around I&apos;ve found that Gtk&apos;s ImageDiff crashes can easily be fixed. I&apos;ve opened bug #85476 for that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>615175</commentid>
    <comment_count>13</comment_count>
      <attachid>139647</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-03 05:12:27 -0700</bug_when>
    <thetext>Comment on attachment 139647
Patch

Clearing flags on attachment: 139647

Committed r115962: &lt;http://trac.webkit.org/changeset/115962&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>615177</commentid>
    <comment_count>14</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2012-05-03 05:12:35 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>139640</attachid>
            <date>2012-05-01 09:37:32 -0700</date>
            <delta_ts>2012-05-01 10:17:21 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-85292-20120501183731.patch</filename>
            <type>text/plain</type>
            <size>1718</size>
            <attacher name="Zan Dobersek">zan</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTE1NzI4CmRpZmYgLS1naXQgYS9Ub29scy9DaGFuZ2VMb2cg
Yi9Ub29scy9DaGFuZ2VMb2cKaW5kZXggOTgyY2Q0YzU4ZmQ0MjRiZjNiZGUzNGQ1NDYxNDZlYWQ3
ZmM3NDZkMS4uZGFlMDRlYzMyODE4ODk4NGE0NWU3MDE0MTJmOWNkODRjM2Q3YTRmMiAxMDA2NDQK
LS0tIGEvVG9vbHMvQ2hhbmdlTG9nCisrKyBiL1Rvb2xzL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2
IEBACisyMDEyLTA1LTAxICBaYW4gRG9iZXJzZWsgIDx6YW5kb2JlcnNla0BnbWFpbC5jb20+CisK
KyAgICAgICAgSW1hZ2VEaWZmIHNob3VsZCBiZSBydW4gaW5zaWRlIGEgcHJvcGVybHkgZXN0YWJs
aXNoZWQgZW52aXJvbm1lbnQKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19i
dWcuY2dpP2lkPTg1MjkyCisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisK
KyAgICAgICAgV2hlbiBjcmVhdGluZyB0aGU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W5kID0gW3NlbGYuX3BhdGhfdG9faW1h
Z2VfZGlmZigpLCAnLS10b2xlcmFuY2UnLCBzdHIodG9sZXJhbmNlKV0KLSAgICAgICAgcHJvY2Vz
cyA9IHNlcnZlcl9wcm9jZXNzLlNlcnZlclByb2Nlc3Moc2VsZiwgJ0ltYWdlRGlmZicsIGNvbW1h
bmQpCisgICAgICAgIGVudmlyb25tZW50ID0gc2VsZi5fcG9ydC5zZXR1cF9lbnZpcm9uX2Zvcl9z
ZXJ2ZXIoJ0ltYWdlRGlmZicpCisgICAgICAgIHByb2Nlc3MgPSBzZXJ2ZXJfcHJvY2Vzcy5TZXJ2
ZXJQcm9jZXNzKHNlbGYsICdJbWFnZURpZmYnLCBjb21tYW5kLCBlbnZpcm9ubWVudCkKIAogICAg
ICAgICBwcm9jZXNzLndyaXRlKCdDb250ZW50LUxlbmd0aDogJWRcbiVzQ29udGVudC1MZW5ndGg6
ICVkXG4lcycgJSAoCiAgICAgICAgICAgICBsZW4oYWN0dWFsX2NvbnRlbnRzKSwgYWN0dWFsX2Nv
bnRlbnRzLAo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>139647</attachid>
            <date>2012-05-01 10:17:31 -0700</date>
            <delta_ts>2012-05-03 05:12:27 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-85292-20120501191730.patch</filename>
            <type>text/plain</type>
            <size>1746</size>
            <attacher name="Zan Dobersek">zan</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTE1NzMzCmRpZmYgLS1naXQgYS9Ub29scy9DaGFuZ2VMb2cg
Yi9Ub29scy9DaGFuZ2VMb2cKaW5kZXggN2Y2NzVmOWMzMTJmMWMwMjZhNTVkZWMxM2JlNzc3MWY2
M2U5Nzc1ZS4uZTRiYjkwMzdiNzAzMmU1ZmIxYTUxMTYzN2VmZWZlNzJkODAzMjkyNiAxMDA2NDQK
LS0tIGEvVG9vbHMvQ2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