New issue
Advanced search Search tips

Issue 747389 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jul 24
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

getCTM gives incorrect results for elements that are not connected to the document

Reported by dmaj...@voltdb.com, Jul 21 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4

Steps to reproduce the problem:
1. I think it is related to  issue 716711 
2. I use getCTM, followed by matrixTransform
3. the output is not as expected

What is the expected behavior?
the matrix transform should give the new transformed coordinates

What went wrong?
I am not exactly sure if the issue is with getCTM or matrixTransform but the output seems to be same as the input when I use it (it is not transformed) - the code worked in earlier versions and I had not changed it since then, but after I updated Chrome, now it doesn't work but it still works on Safari..

Did this work before? Yes I think v 57

Chrome version: <Copy from: 'about:version'>  Channel: n/a
OS Version: OS X 10.12.5
Flash Version:
 

Comment 1 by f...@opera.com, Jul 21 2017

Components: -Blink Blink>SVG
Could you share a URL or a file or a fiddle that illustrates the issue? (It's difficult to assess the issue without it.)

Comment 2 Deleted

I have a function like so

var theta2 = 30;
var line1 = $(newG).find('#line1');
line1.attr('x2', 200);
line1.attr('x2', 200+l);
line1.attr("transform", "rotate(" + -theta2 + ", 200, 200)");

var svg = svgDoc.getElementById("svgdoc");
var p1 = getRelativeXY(200+l, 200, svg, line1[0]);

function getRelativeXY(x, y, svg, element){
	var p = svg.createSVGPoint();
	var ctm = element.getCTM();
	p.x = x;
	p.y = y;
	return p.matrixTransform(ctm);
}

I use this code to get the transformed coordinates of the tip of the line after rotation. Now it does not give the expected coordinates

I pass input a line and the svg element to find the coordinates 

Comment 4 by f...@opera.com, Jul 21 2017

Labels: Needs-Feedback
Ok, could you provide a working (preferably minimal) example that demonstrates the issue? Without seeing the structure (of ancestors) that getCTM() needs to consider, it's difficult to check if there's something wrong.
Ok, I found the issue when making a simple minimal example. In earlier versions of Chrome, we could getCTM() on elements which are just created from code and not yet added to svg using addChild().
Now the getCTM() does not give correct values if the element created is not appended to the svg.

Thanks!

Comment 6 by f...@opera.com, Jul 24 2017

Labels: -Needs-Feedback OS-Android OS-Chrome OS-Linux OS-Windows
Status: Available (was: Unconfirmed)
Summary: getCTM gives incorrect results for elements that are not connected to the document (was: getCTM and matrixTransform not giving expected output)
Ok, that's probably because of issue 369942 (not  issue 716711 .) Calling get{Screen,}CTM on an element that is not connected to the document is not guaranteed to give a correct result. We could restore the old fallback behavior, but it would still only mean that it works sometimes and gives the incorrect result sometimes. (IIRC Firefox behaves in a similarly unreliable way.)
Would you like us to restore the old fallback behavior?
Oh ok. But the issue which you refer to is from May 2014 (upto Dec 2016) but my code worked even earlier this year (even unto around March 2017) in Chrome versions before 57 (approximate version).

I would not recommend the "incorrect result sometimes" behavior but just would like to know the exact issue or change which caused this (maybe it might help you also for related issues by others in future)

Comment 8 by f...@opera.com, Jul 24 2017

https://bugs.chromium.org/p/chromium/issues/detail?id=369942#c25 would be the relevant change from that issue. That looks like it would have first been available in 57, which was released in early March.
Ok., Thanks for the update. I will use the new updated version of Chrome behavior. Thanks! 

Comment 10 by f...@opera.com, Jul 24 2017

The "issue" as such is that 'transform' is now a presentation attribute, and because of implementation details computed style is not available when an element is not connected to the document. (You would be able to observe this issue earlier as well if you had specified 'transform' as a CSS property on the element.)
Some things that has an effect on the transform of an element does not "suffer" from this limitation though - hence the "sometimes". This of course also means that a transform computed on an element not connected to the document could differ from the transform it will get when it _is_ connected to the document - even prior to the mentioned change. The same is also true for elements that _are_ connected to document but is not in the rendering tree (i.e has 'display: none' on itself or an ancestor.)
So relying on a transform computed on an element in any of these cases is perilous at best...
Project Member

Comment 11 by sheriffbot@chromium.org, Jul 24

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: WontFix (was: Untriaged)
As I understand it this is WontFix because we cannot guarantee any sensible behavior.

Re-open if I'm wrong.

Sign in to add a comment