Try the code below that draws 10000 lines in chrome and in firefox. In firefox it runs extremely slow (3-4 seconds), in chrome it runs much faster. I am writing application that draw in animation thousands of lines in frame. Does anybody know how to accelerate firefox? (the hardware acceleration in firefox is swith on).
<!DOCTYPE html>
<body>
<html>
<canvas id="myCanvas"></canvas>
</html>
</body>
<script>
var canvas=document.getElementById("myCanvas");
var context=canvas.getContext("2d");
canvas.width=1000;
canvas.height=600
context.strokeStyle="black";
context.lineWidth=0.3;
context.fillStyle="#8ED6FF";
context.fillRect(0,0,1000,800);
var N=10000;
for (var i=0;i<N;i++){
context.moveTo(500,300);
context.lineTo(500+200*Math.cos(6.28*i/N),300-200*Math.sin(6.28*i/N));
}
context.stroke();
</script>
You can probably use a “beginPath” call at the beginning of each loop iteration:
But I think that mainly you have revealed a bug in Firefox, because as you said, in other browsers is just OK.