DOMMatrix does not keep sign bit with -0
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox69 | --- | affected |
People
(Reporter: saschanaz, Unassigned)
References
(Blocks 1 open bug, )
Details
(Whiteboard: [domcore-bugbash-triaged])
const x = new DOMMatrix();
x.m13 = -0;
x.is2D // true as expected
x.m13 // expected -0, actual 0
This is because we don't store 3D elements on a 2D matrix and instead always return the default values for them. Fixing this doesn't seem to be simple and pretty, maybe we have to always use a 3D matrix, or we define dedicated members for the sign bits, either way not very pretty.
:bzbarsky, What do you think?
Comment 1•7 years ago
|
||
I need to think about this a bit...
Comment 2•7 years ago
|
||
So I guess one question is: is there a good reason to store the 2d case as a 2d matrix? Does it really materially affect performance of anything? I guess it saves a bit of memory...
Kip, do you know who might know this? You seem to be somewhat familiar with the 3d matrix code....
Comment 3•7 years ago
|
||
When implementing fixes for CSS 3d transforms some time back, I encountered this code. IIUC, other than the performance / memory overhead of handing the additional members, the 2d operations could be performed with the same functions by populating the top 3x3 portion of the Matrix4x4. Some functions may be missing in the Matrix4x4; however, and need to be implemented -- integer rounding functions come to mind.
At the time, I did not have the confidence to unify the code, but could certainly see some advantages to doing so.
I would expect much of the overhead being introduced by code in Matrix4x4 that deals with various edge cases such as reversing projection matrices and calculating bounds of transformed homogeneous coordinates. Perhaps checks for these cases are not needed so much for the 2d variants.
I hope this helps!
Updated•7 years ago
|
Comment 4•6 years ago
|
||
So I think we have the following options, at least:
-
When
-0is set, switch to aMatrix4x4, but keep claiming "is2d" is true to script while working with theMatrix4x4under the hood. -
Keep track of the
-0out-of-band, with 8 booleans that can be set to true to indicate that the relevant property is-0instead of0, and modify accessors for the relevant properties and theDOMMatrixReadOnly::Ensure3DMatrixcode to consult those booleans.
Thoughts on which of those would work better? Any other ideas? This is our last DOMMatrix test failure so it might be nice to wrap it up...
Comment 5•6 years ago
|
||
I suspect that adding so many booleans and conditional logic would be less performant than just doing the math on the whole 4x4 matrix every time. I've got to dig in a bit deeper to see what is precisely happening, so will leave NI up and follow up further.
Comment 6•6 years ago
|
||
Another option is to change the spec to match what Gecko does, or to set is2D to false when assigning -0.
| Reporter | ||
Comment 7•6 years ago
|
||
to set is2D to false when assigning -0.
I like this, as a 2D matrix containing 3D information is just nonsense.
Comment 8•6 years ago
|
||
Simon, if there's interest in that from other browsers, that would be just fine, obviously. :)
Comment 9•6 years ago
|
||
Updated•3 years ago
|
Updated•1 year ago
|
Description
•