DmitryBaranovskiy / raphael

JavaScript Vector Library
https://dmitrybaranovskiy.github.io/raphael/
MIT License
11.27k stars 1.67k forks source link

Performance Issues in IE #31

Closed sbj42 closed 15 years ago

sbj42 commented 15 years ago

Using the following test code at http://raphaeljs.com/playground.html

var t0 = new Date();
for (var i = 0; i < 500; i ++) {
  paper.rect(Math.random()*400, Math.random()*400, 10, 10).attr({stroke: "#f88", fill: "#f88"});
}
var t1 = new Date();
paper.text(100, 100, "Time: "+(t1-t0)+" ms");

Here are my results over several trials:

BrowserTime (ms)
Chrome 2.0.172.37100
Firefox 3.5825
Firefox 3.5.1525
IE 8.0.6001.1878317,500
IE 6.0.2900.2180.xpsp_sp2_gdr.090206-123328,000

In other tests I have seen some improvement by creating the canvas in a new element that isn't in the DOM tree, and then moving the canvas into the DOM tree after the objects are created, but there are still big differences between the speeds.

Of course I'm sure it's impossible to get all browsers to perform identically, but I'm submitting this issue because I believe that the very high numbers for IE may be due to a bug in Raphael's VML processing. More research will be necessary to confirm this.

sbj42 commented 15 years ago

After some experimentation, I have found that the problem lies in the top-level vml group element that Raphael creates. IE tends to slow down when the group element contains large numbers of sub-elements.

I was able to improve speed greatly in simple test cases by removing the top-level group element entirely. So far I'm unable to patch Raphael to do this, because there's a lot of crazy group code in there that I don't understand.

chasbeen commented 15 years ago

sbj42 heres a cross reference to the issue. Maybe it ties in with your research? http://github.com/DmitryBaranovskiy/raphael/issues/closed/#issue/13

DmitryBaranovskiy commented 15 years ago

top level group has been removed. Didn’t notice any performance improvements. Not on this test anyway.

sbj42 commented 15 years ago

Raphael 0.8.6 resolves this issue for me. Running the test again, I get these results:

BrowserTime (ms)
Chrome 2.0.172.39320
Firefox 3.5.2185
IE 8.0.6001.18813802
IE 6.0.2900.2180.xpsp_sp2_gdr.090206-12332,500

Note that the versions on most of those browsers are different from the original test, so this isn't a perfect re-test of the issue. I didn't mention it in my original post, but I think the Raphael version for the first test was 0.8.2.

DmitryBaranovskiy commented 15 years ago

Improved in 1.0. It will never be perfect, but I will close issue.