This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The 2dcontext.setTransform method specification doesn't say how to react when passed a singular matrix.
I'd expect that if the transformation matrix is singular, nothing that's affected by the transformation matrix should be displayed, since it would make everything zero pixels thick. What do browsers do?
WebKit apparently notes that it has a singular matrix and ignores every operation. Firefox doesn't handle it at all. Personally, I'd like to see it throw an error, since using a singular matrix as a transform doesn't make much sense.
Yeah, it probably does make the most sense to ignore it or throw an exception or something. Problem: how do you define "singular"? 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?
Let a b c d be a matrix where a, b, c, d are some floating point data type. We'll say it's singular iff a*d == c*b. This mostly defeats mistakes like passing the zero matrix or a simple non-invertible one. I'm not sure why we'd have to worry about them being close to equal. It should only arise with pathological matrices.
You can *never* rely on equality for floating-point. Rounding errors mean that basic mathematical identities don't hold, like (a*b)*c == a*(b*c) or (a/b)*b == a. Having a determinant almost exactly zero wouldn't have to be pathological at all, it could be any matrix that went through some numeric operations. For instance: data:text/html,<!doctype html><script>alert((10/3000 - 2 + 2)*3000 == 10)</script> alerts false in Firefox 4.0, Chrome 12 dev, and Opera 11.10.
I realize floating comparisons are bad, but it's what browsers currently use afaict.
Do you have a specific test-case? I don't know enough about canvas to easily make one, but I'd be interested in fiddling and seeing how browsers behave here. Your description in comment 2 makes it sound like WebKit doesn't handle singular matrices specially at all, it just draws everything with zero width. If that's correct, presumably it behaves the same if the eigenvalues are both very small, not just if they're zero (since the width will round down to zero).
Created attachment 989 [details] singular and almost singular matrix example Here is an example of a almost singular matrix and a singular matrix being used to transform.
WebKit "handles" singular matrices by detecting when there are in effect and ignoring every operation on the canvas while they are.
Your "almost singular" matrix isn't very close to singular at all. It has a determinant of .00002. That'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's 0.00000001, Firefox doesn't draw anything, even though w(1 - e == 1) logs "false". 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't seem to be just testing whether it's actually singular, it looks like they're testing that it's just "close" to singular.
Why can't implementations just do the maths as suggested by the spec? I don't understand why a special case is needed here.
I don't understand why either, but it seems like implementations do have the special case.
mass-move component to LC1
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?
EDITOR'S RESPONSE: This is an Editor'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't have a specific revision to point to at this time) Rationale: Concurred with reporter's comments.