Contact emails
jinho...@samsung.com, caba...@adobe.com, dsch...@chromium.org
Spec
http://dev.w3.org/fxtf/geometry/
Summary
The specification provides basic geometric interfaces to represent points, rectangles,
quadrilaterals and transformation matrices that can be used by other modules or specifications.
We will implement following things:
- DOMMatrix Interface
- DOMRect Interface
- DOMRectList Interface
- DOMQuad Interface
- DOMPoint interface
Motivation
The SVG interfaces SVGPoint, SVGRect and SVGMatrix are aliasing the here defined interfaces
in favor for common interfaces used by SVG, Canvas 2D Context and CSS Transforms.
Compatibility Risk
Low, These are already being implemented in Firefox and WebKit (Rik and Dirk)
Ongoing technical constraints
None
Will this feature be supported on all five Blink platforms (Windows, Mac, Linux, Chrome OS and Android)?
Yes
OWP launch tracking bug?
Link to entry on the feature dashboard
http://www.chromestatus.com/features/6015941766807552
Requesting approval to ship?
No
- DOMRectList Interface
Contact emails
jinho...@samsung.com, caba...@adobe.com, dsch...@chromium.org
Spec
http://dev.w3.org/fxtf/geometry/
Summary
The specification provides basic geometric interfaces to represent points, rectangles,
quadrilaterals and transformation matrices that can be used by other modules or specifications.
We will implement following things:
- DOMMatrix Interface
- DOMRect Interface
- DOMRectList Interface
- DOMQuad Interface
- DOMPoint interface
Motivation
The SVG interfaces SVGPoint, SVGRect and SVGMatrix are aliasing the here defined interfaces
in favor for common interfaces used by SVG, Canvas 2D Context and CSS Transforms.
Compatibility Risk
Low, These are already being implemented in Firefox and WebKit (Rik and Dirk)
Ongoing technical constraints
None
Will this feature be supported on all five Blink platforms (Windows, Mac, Linux, Chrome OS and Android)?
Yes
OWP launch tracking bug?
Link to entry on the feature dashboard
http://www.chromestatus.com/features/6015941766807552
Requesting approval to ship?
No
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
> I think the point Domenic is making is that the places that currently return DOMRectList should just return a sequence<DOMRect>.
Yes, exactly.
When I originally wrote the email, I wasn't aware that there are parts of the platform already making use of DOMRectList, since my impression this was an intent to implement new interfaces. It looks like at the least getClientRects does; does anyone else?
I see two paths forward:
- If implementers are willing to try it, converting to a real array (WebIDL "sequence") would be ideal and greatly improve the developer experience.
- If we don't want to spend the time testing such a change (which is understandable), then I'd recommend DOMRectList get [NoInterfaceObject], and rename it LegacyGetClientRectsReturnValueType or some such so that it gets hidden as far away from developers as possible, and so no spec uses it in the future.
On Wed, Jun 25, 2014 at 10:05 PM, Rik Cabanier <caba...@gmail.com> wrote:I'm not sure introducing a subclass of Array with item() is worth it
> Are you saying that we should replace the current API with a subclassed
> array class but only if this subclass will be used in other places?
for this specific legacy *List interface. But if we can replace a
bunch of them...
> Given this, maybe we should just stick with the current definition.
> If we decide later that it needs the additional array-like behavior, we can add it then.
The question is, do we ever expect developers to use this type? If so, we should fix it as soon as is feasible (i.e., as soon as browser ship ES6 built-in subclassing). If no new code uses getClientRects(), e.g. because getBoxQuads() is better, then I guess we can just leave it as another warty old API.
> I do agree with Dominic that we should make it a [NoInterfaceObject] object.
We should also ensure no other specs ever use this type, with an appropriately-scary name, and probably a note in the spec as well.
From: Rik Cabanier <caba...@gmail.com>
The question is, do we ever expect developers to use this type? If so, we should fix it as soon as is feasible (i.e., as soon as browser ship ES6 built-in subclassing). If no new code uses getClientRects(), e.g. because getBoxQuads() is better, then I guess we can just leave it as another warty old API.
> Given this, maybe we should just stick with the current definition.
> If we decide later that it needs the additional array-like behavior, we can add it then.
> I do agree with Dominic that we should make it a [NoInterfaceObject] object.We should also ensure no other specs ever use this type, with an appropriately-scary name, and probably a note in the spec as well.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
I am concerned about the performance of these APIs, particularly DOMMatrix.A javascript polyfill will be faster than the native DOMMatrix as it's implemented today. I do not think we should be dropping performance landmines for graphics developers to trip over, even at the cost of making the APIs more complex (e.g., taking typed arrays instead of slow objects).Is performance a concern?
Can we do something better on the implementation side?
On Tue, Aug 26, 2014 at 12:40 PM, Philip Rogers <p...@chromium.org> wrote:
I am concerned about the performance of these APIs, particularly DOMMatrix.A javascript polyfill will be faster than the native DOMMatrix as it's implemented today. I do not think we should be dropping performance landmines for graphics developers to trip over, even at the cost of making the APIs more complex (e.g., taking typed arrays instead of slow objects).Is performance a concern?It would be great to have some data on the performance. It's likely that crossing into the c++ side takes up more cycles than the actual implementation :-)Jinho did want to implement it using blink-in-javascript but had to abandon that idea since it doesn't support constructors.
Rik,I've now read the webkit [1] and mozilla [2] threads on this topic and it looks like these issues have been covered before. I do not think we should ship the geometry interfaces in Blink. DOMMatrix and friends will be slow in Blink for the same reasons WebKit balked at them [3]. As the blink-in-js docs [4] say, blink-in-js should not be used for high-performance apis like this. Maybe we can use typed arrays for these APIs instead?
An alternative is to implement and standardize these interfaces as first-class citizens in Ecmascript.
On Tue, Aug 26, 2014 at 3:01 PM, Philip Rogers <p...@chromium.org> wrote:
Rik,I've now read the webkit [1] and mozilla [2] threads on this topic and it looks like these issues have been covered before. I do not think we should ship the geometry interfaces in Blink. DOMMatrix and friends will be slow in Blink for the same reasons WebKit balked at them [3]. As the blink-in-js docs [4] say, blink-in-js should not be used for high-performance apis like this. Maybe we can use typed arrays for these APIs instead?Like you said, we covered that approach in the past. Typed arrays are not author friendly and will need additional JS libraries to make them useful.I also doubt that type arrays will be faster as the C++ side will now have to look into the JS VM to get the values out.DOMMatrix as currently proposed, is basically a drop-in replacement of the existing SVGMatrix class along with some extra methods and abstractions to address its shortcomings. (I noticed that we didn't add DOMMatrixInit to the spec yet. It's a dictionary with the attributes of DOMMatrix and will be used in methods that take a DOMMatrix as an argument)An alternative is to implement and standardize these interfaces as first-class citizens in Ecmascript.I believe Dirk looked into this and it didn't look encouraging.
I think we need hard data to see if there's actually a problem. I will try to run some tests and come back with results.
Rik,I've now read the webkit [1] and mozilla [2] threads on this topic and it looks like these issues have been covered before. I do not think we should ship the geometry interfaces in Blink. DOMMatrix and friends will be slow in Blink for the same reasons WebKit balked at them [3]. As the blink-in-js docs [4] say, blink-in-js should not be used for high-performance apis like this. Maybe we can use typed arrays for these APIs instead?
An alternative is to implement and standardize these interfaces as first-class citizens in Ecmascript.
On Tue, Aug 26, 2014 at 3:01 PM, Philip Rogers <p...@chromium.org> wrote:
Rik,I've now read the webkit [1] and mozilla [2] threads on this topic and it looks like these issues have been covered before. I do not think we should ship the geometry interfaces in Blink. DOMMatrix and friends will be slow in Blink for the same reasons WebKit balked at them [3]. As the blink-in-js docs [4] say, blink-in-js should not be used for high-performance apis like this. Maybe we can use typed arrays for these APIs instead?I wrote a small test case: http://jsperf.com/dommatrix-perfIt applies a typical translate/scale/rotate sequence to a DOMMatrix and a JS equivalent.Benchmarking this in Firefox Nightly (because the functionality is not in Chrome yet) shows that the JS implementation is 3 to 4 times faster. This is expected since crossing into the c++ side slows things down.To make a more realistic case, I added another test that calls setLineDash with the JS array to simulate a DOM crossing. I verified that the C++ side just verifies the contents of that array and stores it in the canvas state. That test is almost twice as slow as the DOMMatrix test.(I also tried typed arrays but they were slower than native JS arrays)This tells me that there is no performance problem with DOMMatrix.
In addition, jsperf reports that on my core i-7 3.4 GHz, I can do 360,000 translate/scale/rotate sequences per second.So, if I animate 100 objects simultaneously, DOMMatrix will only take up: 100 objects * 60fps / 360,0000 ops = 0.017s
On Wed Sep 03 2014 at 10:30:16 AM Rik Cabanier <caba...@gmail.com> wrote:
On Tue, Aug 26, 2014 at 3:01 PM, Philip Rogers <p...@chromium.org> wrote:
Rik,I've now read the webkit [1] and mozilla [2] threads on this topic and it looks like these issues have been covered before. I do not think we should ship the geometry interfaces in Blink. DOMMatrix and friends will be slow in Blink for the same reasons WebKit balked at them [3]. As the blink-in-js docs [4] say, blink-in-js should not be used for high-performance apis like this. Maybe we can use typed arrays for these APIs instead?I wrote a small test case: http://jsperf.com/dommatrix-perfIt applies a typical translate/scale/rotate sequence to a DOMMatrix and a JS equivalent.Benchmarking this in Firefox Nightly (because the functionality is not in Chrome yet) shows that the JS implementation is 3 to 4 times faster. This is expected since crossing into the c++ side slows things down.To make a more realistic case, I added another test that calls setLineDash with the JS array to simulate a DOM crossing. I verified that the C++ side just verifies the contents of that array and stores it in the canvas state. That test is almost twice as slow as the DOMMatrix test.(I also tried typed arrays but they were slower than native JS arrays)This tells me that there is no performance problem with DOMMatrix.3-4x slower seems like a performance problem...
In addition, jsperf reports that on my core i-7 3.4 GHz, I can do 360,000 translate/scale/rotate sequences per second.So, if I animate 100 objects simultaneously, DOMMatrix will only take up: 100 objects * 60fps / 360,0000 ops = 0.017sHow long does it take on a phone? Do you think the web platform can afford to give away 3-4x performance and still be competitive on mobile?
On 9/3/14, 5:35 PM, Rik Cabanier wrote:I doubt it's a bug in the JIT. It's the _native_ version that's slower on Windows, not the JS version! In any case, it's definitely a Windows-specific issue.
I talked to the mozilla people and this is a bug in the JIT in Firefox
for Windows.
On Mac and Linux, DOMMatrix is actually faster than the JS
implementation with no DOM interaction.
If you pass to a DOM method that expects a sequence<float>, sure: Gecko doesn't have a fast path for convering a Float32Array to a sequence<float> in the DOM bindings at the moment.I also added tests that use float arrays. They are about the same speed
as DOMMatrix as long as you don't interact with the DOM. As soon as you
cross the DOM, native JS is 4 to 5 times slower than DOMMatrix.