ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 752 forks source link

getImageData on linux too slow #1030

Open pfautrero opened 10 years ago

pfautrero commented 10 years ago

Hi, It is not exactly a bug report and don't know if it is already reported. For now, it is just an information. In fact, using kinetic 5.1.0 in my project let me highlight that _getIntersection is very slow on linux (not on windows and MAC OS X). I tried to find the culprit and it seems to be getImageData method. Some old bugreport on bugzilla talk about this subject: https://bugzilla.mozilla.org/show_bug.cgi?id=550845

To solve this issue, I had to modify _getIntersection method to avoid as often as possible the getImageData call. The idea is to call getImageData once on the entire hitarea, store the result somewhere in an array and when _getIntersection is called, just parse this array to find the right pixel.

Hope kineticjs guys will have a look at this problem (if not already done!) :-)

Thanks and keep the good work, kinetic is amazing !

lavrton commented 10 years ago

Do you mean bad performance while dragging? Try latest version from master. How it works for you?

pfautrero commented 10 years ago

Well, it is not really on drag and drop feature. Let's look at these examples. Help the rabbit to catch the carrot. This version is kinetic 5.1.0 I modified on _getIntersection : http://pascal-fautrero.ac-versailles.fr/kinetic/test510modified/

This one is the 5.1.1 I compiled some days ago : http://pascal-fautrero.ac-versailles.fr/kinetic/test511/

ubuntu or debian with firefox : Look at the pointer when you leave the rabbit. Switching to default pointer is not immediat with 5.1.1. With 5.1.0, the switch is immediat.