Automattic / Automattic/node-canvas

fillRect and strokeRect are slow after arc

Open
#626 3 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

I only noticed this obscure behavior because of the benchmarks, and it doesn't affect me, but logging it.

``` javascript
var Canvas = require('./lib/canvas');
var canvas = new Canvas(200, 200);
var ctx = canvas.getContext('2d');
console.time("fillRect");
ctx.fillRect(50, 50, 100, 100);
console.timeEnd("fillRect"); // **1 ms**
for (var i = 0; i < 100000; i++) {
ctx.arc(75,75,50,0,Math.PI*2,true);
}
console.time("fillRect");
ctx.fillRect(50, 50, 100, 100);
console.timeEnd("fillRect"); // **1531 ms**
```

This is why [the benchmarks show `fillRect` running at <1 op/sec](https://travis-ci.org/Automattic/node-canvas/jobs/79960720#L3259).

Profiling shows cairo consuming 80% of the cycles. Might be fixed in a newer version of cairo.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.