I'm having a lot of fun with this, but ran into this performance issue.
I'm using the Display module to render a rectangular display, and getting 100% cpu usage from this line:
/**
* Timer tick: update dirty parts
*/
_tick() {
this._backend.schedule(this._tick);
if (!this._dirty) {
return;
}
backend.schedule() is this line:
schedule(cb) { requestAnimationFrame(cb); }
It appears that, as long as there's nothing to do, it just executes and returns as fast requestAnimationaly possible. Adding a 2ms setTimeout to this._backend.schedule(this._tick) dropped chrome's cpu usage from 100% to 7%.
Implementing an optional rate limiter would trivial, but I wanted to make sure that I'm not using it wrong before submitting a PR?
I'm having a lot of fun with this, but ran into this performance issue.
I'm using the Display module to render a rectangular display, and getting 100% cpu usage from this line:
backend.schedule() is this line:
It appears that, as long as there's nothing to do, it just executes and returns as fast
requestAnimationalypossible. Adding a 2mssetTimeouttothis._backend.schedule(this._tick)dropped chrome's cpu usage from 100% to 7%.Implementing an optional rate limiter would trivial, but I wanted to make sure that I'm not using it wrong before submitting a PR?