Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance by running canvas.renderAll only once per frame #3945

Closed
thani-sh opened this issue May 18, 2017 · 3 comments
Closed

Improve performance by running canvas.renderAll only once per frame #3945

thani-sh opened this issue May 18, 2017 · 3 comments

Comments

@thani-sh
Copy link

Hi,

I'm checking out fabricjs these days for a project we're planning to do. While experimenting with Fabric and Chrome DevTools, I came across following.

screen shot 2017-05-18 at 4 45 35 pm

It appears that canvas.renderAll is running multiple times per browser render frame. It's triggered by the mouse event. I tried adding the following hack and the frame rate increased a bit.

let isRendering = false;
const render = canvas.renderAll.bind(canvas);

canvas.renderAll = () => {
    if (!isRendering) {
        isRendering = true;
        requestAnimationFrame(() => {
            render();
            isRendering = false;
        });
    }
};

Is it possible to improve FabricJS performance when using mouse events this way? Thanks.

@asturur
Copy link
Member

asturur commented May 18, 2017

yes we have already a ticket for this that is about implememting requestAnimationFrame

@asturur
Copy link
Member

asturur commented May 18, 2017

duplicate of #1979

@asturur asturur closed this as completed May 18, 2017
@asturur
Copy link
Member

asturur commented May 18, 2017

is something i have to do anyway soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants