<?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>62204</bug_id>
          
          <creation_ts>2011-06-07 05:15:49 -0700</creation_ts>
          <short_desc>Master bug for rounding issues which cause 1px difference on 32/64 bit architectures</short_desc>
          <delta_ts>2024-01-02 09:17:43 -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>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</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>
          <dependson>42624</dependson>
    
    <dependson>47467</dependson>
    
    <dependson>52810</dependson>
    
    <dependson>54474</dependson>
    
    <dependson>56465</dependson>
    
    <dependson>62003</dependson>
    
    <dependson>65831</dependson>
    
    <dependson>72254</dependson>
    
    <dependson>82601</dependson>
    
    <dependson>89597</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Zoltan Herczeg">zherczeg</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abecsi</cc>
    
    <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>loki</cc>
    
    <cc>ossy</cc>
    
    <cc>tonikitoo</cc>
    
    <cc>vanuan</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>416441</commentid>
    <comment_count>0</comment_count>
    <who name="Zoltan Herczeg">zherczeg</who>
    <bug_when>2011-06-07 05:15:49 -0700</bug_when>
    <thetext>Such bugs are mostly caused by rounding. But what does exactly happen there? And how?

The answer is here, let&apos;s divide 400000 by 600

If the input arguments are float:  400000/600 = 666.666687
If the input arguments are double: 400000/600 = 666.666667

This is nice, but shouldn&apos;t the same rounding error should happen on ALL machines?

The understand this better, we need to see what exactly happen on lower (machine code) levels. The systems use registers to temporary keep the values of arithmetic. On x86, these registers have fixed size (10 byte for x87 fpu, and 8 byte for SSE2), and all arithmetic operations are executed using the highest precision. However, results are rounded to the storage size if we move the data to the memory.

Let&apos;s we have a super simple x86 machine with 2 double precision registers, d1 and d2, and we want to evaluate: (A*B)+(C*D). The following pesudo code show this:

LOAD A to d1
MULTIPLY B to d1
LOAD C to d2
MULTIPLY D to d2
ADD d1 and d2

However, what does happen, if let&apos;s say, d2 is reserved for some reasons:

LOAD A to d1
MULTIPLY B to d1
STORE d1 to [4 byte mem area]   // CONVERSION HERE!!!
LOAD C to d2
MULTIPLY D to d2
ADD d1 and [4 byte mem area]

There are several versions of such code, but the issue is the same: moving data to a storage with different precision cause rounding. However, if the data is not need to be moved (because it is in the right register at the moment), the rounding is ALSO optimized out by the compiler, and you may get a different result on different platforms.

Solution? I can&apos;t see a good solution. Storing everything on the highest precision would increase the memory consumption too much. Furthermore, these differences are hardly visible to the user. However, it is a nightmare for platform maintainers, you need to maintain too many expected files. I think we should live with it now, and try to reduce these bugs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416444</commentid>
    <comment_count>1</comment_count>
    <who name="Zoltan Herczeg">zherczeg</who>
    <bug_when>2011-06-07 05:28:47 -0700</bug_when>
    <thetext>&gt; LOAD A to d1
&gt; MULTIPLY B to d1
&gt; STORE d1 to [4 byte mem area]   // CONVERSION HERE!!!
&gt; LOAD C to d2
&gt; MULTIPLY D to d2
&gt; ADD d1 and [4 byte mem area]

My bad, the second example was wrong. It should look like:

LOAD A to d1
MULTIPLY B to d1
STORE d1 to [4 byte mem area]   // CONVERSION HERE!!!
LOAD C to d1
MULTIPLY D to d1
ADD d1 and [4 byte mem area]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416529</commentid>
    <comment_count>2</comment_count>
    <who name="Ami Fischman">fischman</who>
    <bug_when>2011-06-07 08:52:04 -0700</bug_when>
    <thetext>FTR, chromium/linux/ia32 builds with -mfpmath=sse -msse2 to avoid this sort of problem:
http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/build/common.gypi&amp;q=file:build/common.gypi&amp;exact_package=chromium&amp;l=1211</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>501506</commentid>
    <comment_count>3</comment_count>
    <who name="">vanuan</who>
    <bug_when>2011-11-13 04:45:36 -0800</bug_when>
    <thetext>Please add this bug https://bugs.webkit.org/show_bug.cgi?id=54474 as a dependency</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>501769</commentid>
    <comment_count>4</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2011-11-14 03:24:22 -0800</bug_when>
    <thetext>Add more dependencies.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1923710</commentid>
    <comment_count>5</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-06 18:05:40 -0800</bug_when>
    <thetext>All dependent bugs are fixed now, do we need to track anything else here? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002520</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-02 09:17:43 -0800</bug_when>
    <thetext>All dependent bugs are fixed. So marking this as &apos;RESOLVED CONFIGURATION CHANGED&apos;. Please reopen renew bug as needed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>