Canvas performance in Dart
canvas, dart, html, performance
Solution
If it works like it does in javascript, your issue is probably with the fact that you're cacheing a CanvasElement and that the drawImage have to retrieve the bitmapData from it each time it is called. This is a really expensive operation.
You could try to cache the imageData with getImageData and draw it with putImageData (both are CanvasRenderingContext2D methods)
Problem
This problem is related to my framework VilTAGE (https://github.com/ViliX64/VilTAGE). It's an ASCII web game framework, that renders to Canvas. The problem is, that the drawing time is twice as long as the computation time. The way the rendering works now is that there is a HashMap of each CharNode (an object, with a text character, color, etc..) and CanvasElement, that has the text drawn onto it. When the loop wants to draw a CharNode (15-30x a second), it goes through the HashMap, find required CanvasElement and renders it to the main CanvasElement. (See https://github.com/ViliX64/VilTAGE/blob/master/lib/etc/utility.dart). The individual CanvasElement snaps are small (usually about 10x10). They are drawn using drawImage(..); The problem is, that in a game with 70x40 CharNodes, the game runs (unsuprisingly) very slow and even more, when compiled to JavaScript. Is there any obvious mistake I am making or could you please give me any tips of improving the performance? EDIT 1: It runs the slowest on Firefox and IE. Performance on Google Chrome is better.