ericdrowell/KineticJS — pull request #314 by louisj (2013-03-14 18:51:18+00:00)
Title: Improved Kinetic.Text performance when dealing with lots of Text elements

I added a cached dummy canvas context that is shared by all instances of Kinetic.Text.
This prevents creating one every time in the _getTextSize method and greatly improves the performance especially on mobile devices. I did test it with hundreds of elements on iPad devices and was able to get a 50 to 60% speed-up.

The canvas is created when the first Kinetic.Text is created.
The obvious drawback is that this cached canvas will remain forever ungarbaged even if all Kinetic.Text element have been removed. If that's a problem, maybe there is something that could be done by sharing it to everybody through Kinetic.Global (or something else?) as i noted that the TextPath object also could need the same trick.