<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12705</bug_id>
          
          <creation_ts>2011-05-19 15:10:37 +0000</creation_ts>
          <short_desc>setTransform spec silent on what to do with singular matrices</short_desc>
          <delta_ts>2011-12-10 00:05:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML Canvas 2D Context</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>canvas</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Benjamin Peterson">benjamin</reporter>
          <assigned_to>contributor</assigned_to>
          <cc>ayg</cc>
    
    <cc>excors</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>48637</commentid>
    <comment_count>0</comment_count>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-19 15:10:37 +0000</bug_when>
    <thetext>The 2dcontext.setTransform method specification doesn&apos;t say how to react when passed a singular matrix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48639</commentid>
    <comment_count>1</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-19 17:21:04 +0000</bug_when>
    <thetext>I&apos;d expect that if the transformation matrix is singular, nothing that&apos;s affected by the transformation matrix should be displayed, since it would make everything zero pixels thick.  What do browsers do?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48641</commentid>
    <comment_count>2</comment_count>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-19 17:44:26 +0000</bug_when>
    <thetext>WebKit apparently notes that it has a singular matrix and ignores every operation. Firefox doesn&apos;t handle it at all. Personally, I&apos;d like to see it throw an error, since using a singular matrix as a transform doesn&apos;t make much sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48642</commentid>
    <comment_count>3</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-19 17:56:06 +0000</bug_when>
    <thetext>Yeah, it probably does make the most sense to ignore it or throw an exception or something.  Problem: how do you define &quot;singular&quot;?  The arguments are doubles.  Do you require that the determinant of {{a, c}, {b, d}} be within epsilon of 0 for some specific epsilon?  What happens if you call transform() when the existing matrix and the matrix you passed to transform() both have determinants greater than epsilon in absolute value, but their product has a determinant smaller than epsilon?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48643</commentid>
    <comment_count>4</comment_count>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-19 18:04:20 +0000</bug_when>
    <thetext>Let
a b
c d
be a matrix where a, b, c, d are some floating point data type. We&apos;ll say it&apos;s singular iff a*d == c*b. This mostly defeats mistakes like passing the zero matrix or a simple non-invertible one. I&apos;m not sure why we&apos;d have to worry about them being close to equal. It should only arise with pathological matrices.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48649</commentid>
    <comment_count>5</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-19 22:16:38 +0000</bug_when>
    <thetext>You can *never* rely on equality for floating-point.  Rounding errors mean that basic mathematical identities don&apos;t hold, like (a*b)*c == a*(b*c) or (a/b)*b == a.  Having a determinant almost exactly zero wouldn&apos;t have to be pathological at all, it could be any matrix that went through some numeric operations.  For instance:

data:text/html,&lt;!doctype html&gt;&lt;script&gt;alert((10/3000 - 2 + 2)*3000 == 10)&lt;/script&gt;

alerts false in Firefox 4.0, Chrome 12 dev, and Opera 11.10.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48650</commentid>
    <comment_count>6</comment_count>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-19 23:49:58 +0000</bug_when>
    <thetext>I realize floating comparisons are bad, but it&apos;s what browsers currently use afaict.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48665</commentid>
    <comment_count>7</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-20 18:48:46 +0000</bug_when>
    <thetext>Do you have a specific test-case?  I don&apos;t know enough about canvas to easily make one, but I&apos;d be interested in fiddling and seeing how browsers behave here.  Your description in comment 2 makes it sound like WebKit doesn&apos;t handle singular matrices specially at all, it just draws everything with zero width.  If that&apos;s correct, presumably it behaves the same if the eigenvalues are both very small, not just if they&apos;re zero (since the width will round down to zero).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48666</commentid>
    <comment_count>8</comment_count>
      <attachid>989</attachid>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-20 20:29:25 +0000</bug_when>
    <thetext>Created attachment 989
singular and almost singular matrix example

Here is an example of a almost singular matrix and a singular matrix being used to transform.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48667</commentid>
    <comment_count>9</comment_count>
    <who name="Benjamin Peterson">benjamin</who>
    <bug_when>2011-05-20 20:31:41 +0000</bug_when>
    <thetext>WebKit &quot;handles&quot; singular matrices by detecting when there are in effect and ignoring every operation on the canvas while they are.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48682</commentid>
    <comment_count>10</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-22 22:38:28 +0000</bug_when>
    <thetext>Your &quot;almost singular&quot; matrix isn&apos;t very close to singular at all.  It has a determinant of .00002.  That&apos;s quite a lot, since your lineWidth is 1999999.  Try something like this instead:

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1002

If I set e to 0.0000001, Firefox draws the red square successfully.  If I add one more zero, so it&apos;s 0.00000001, Firefox doesn&apos;t draw anything, even though w(1 - e == 1) logs &quot;false&quot;.  WebKit seems to have the same magic threshold, after which it just ignores the operation (even though the width variable is large enough that it should really draw the big black line).  So it doesn&apos;t seem to be just testing whether it&apos;s actually singular, it looks like they&apos;re testing that it&apos;s just &quot;close&quot; to singular.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49966</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-06-21 06:14:13 +0000</bug_when>
    <thetext>Why can&apos;t implementations just do the maths as suggested by the spec? I don&apos;t understand why a special case is needed here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50116</commentid>
    <comment_count>12</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-06-22 20:51:52 +0000</bug_when>
    <thetext>I don&apos;t understand why either, but it seems like implementations do have the special case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52790</commentid>
    <comment_count>13</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:04:14 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54671</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-11 05:49:15 +0000</bug_when>
    <thetext>This was also discussed on the WHATWG list:
   http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-June/thread.html#32229

Philip, any advice?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61361</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-12-09 23:26:24 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see recent diffs (sorry I don&apos;t have a specific revision to point to at this time)
Rationale: Concurred with reporter&apos;s comments.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>989</attachid>
            <date>2011-05-20 20:29:25 +0000</date>
            <delta_ts>2011-05-20 20:29:25 +0000</delta_ts>
            <desc>singular and almost singular matrix example</desc>
            <filename>singular.html</filename>
            <type>text/html</type>
            <size>858</size>
            <attacher name="Benjamin Peterson">benjamin</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHRpdGxlPlNpbmd1bGFyIGFuZCBhbG1vc3Qg
c2luZ3VsYXIgdHJhbnNmb3JtczwvdGl0bGU+CjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0
Ij4KZnVuY3Rpb24gdHJhbnNmb3JtKGN0eCwgYSwgYiwgYywgZCwgZSwgZikgewogICAgY3R4Lmxp
bmVXaWR0aCA9IDE5OTk5OTk7CiAgICBjdHguc3Ryb2tlU3R5bGUgPSAiYmxhY2siOwogICAgY3R4
LnNhdmUoKQogICAgY3R4LnNldFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKQogICAgY3R4LnN0
cm9rZVJlY3QoNTAwLCA1MDAsIDEwMCwgMTAwKTsKICAgIGN0eC5yZXN0b3JlKCkKICAgIGN0eC5m
aWxsU3R5bGUgPSAicmVkIjsKICAgIGN0eC5maWxsUmVjdCgxMCwgMTAsIDUwLCA1MCk7Cn0KZnVu
Y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