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

Performance problem: Window module causing unnecessary layout reflow #510

Closed
w0rm opened this Issue Feb 26, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@w0rm

w0rm commented Feb 26, 2016

In the Runtime code there is a draw function that checks for Window module and calls resizeIfNeeded if it exists.

function draw()
{
    update(elm.node.firstChild, savedScene, scheduledScene);
    if (elm.Native.Window)
    {
        elm.Native.Window.values.resizeIfNeeded();
    }
    savedScene = scheduledScene;
}

resizeIfNeeded calls node.clientWidth and node.clientHeight that trigger layout reflow.

Because draw function happens very often, this affects the performance and makes it impossible to use Window module to calculate dimensions in HTML5 games that render on every requestAnimationFrame.

@w0rm w0rm referenced this issue Feb 26, 2016

Closed

Improve performance #17

@w0rm

This comment has been minimized.

Show comment
Hide comment
@w0rm

w0rm Feb 26, 2016

Seems that this is in the project from the old times, tracked the resizeIfNeeded call down until this commit elm-lang@1af7914

w0rm commented Feb 26, 2016

Seems that this is in the project from the old times, tracked the resizeIfNeeded call down until this commit elm-lang@1af7914

@w0rm

This comment has been minimized.

Show comment
Hide comment
@w0rm

w0rm Feb 27, 2016

Below are two timelines of HTML5 game, one before, and another one after I deleted resizeIfNeeded call from the draw function.

screen shot 2016-02-27 at 19 27 05

You can see that the second one is mostly green with the frames painted in less than 20ms.

screen shot 2016-02-27 at 19 30 08

The question is, why is it there in the first place, and can it be removed?

w0rm commented Feb 27, 2016

Below are two timelines of HTML5 game, one before, and another one after I deleted resizeIfNeeded call from the draw function.

screen shot 2016-02-27 at 19 27 05

You can see that the second one is mostly green with the frames painted in less than 20ms.

screen shot 2016-02-27 at 19 30 08

The question is, why is it there in the first place, and can it be removed?

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 11, 2016

Member

I guess it can be removed. I do not think elm-lang/window will have this issue.

Member

evancz commented May 11, 2016

I guess it can be removed. I do not think elm-lang/window will have this issue.

@evancz evancz closed this May 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment