Skip to content

flip animation causes layout thrashing #6733

Open
@wartmanm

Description

@wartmanm

Describe the bug

I have a grid with a large number of elements that I'm animating using flip. It looks great, but it causes the page to freeze up for a few seconds. It seems like fix_position() and create_rule() are causing forced reflows every time they run: fix_position() by interleaving reads to getElementBoundingRect() and getComputedStyle().width, and writes to style.position, and create_rule() by interleaving reads to getElementBoundingRect() and adding style rules.

Reproduction

https://svelte.dev/repl/06ac8d7e24264c5998082b168364df7d?version=3.42.4

Logs

https://share.firefox.dev/3l28BC1

System Info

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
    Memory: 64.80 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.9.0 - /usr/local/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 7.21.1 - /usr/local/bin/npm
    Watchman: 2021.08.30.00 - /usr/local/bin/watchman
  npmPackages:
    rollup: ^2.3.4 => 2.56.3
    svelte: ^3.0.0 => 3.42.4

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    perfruntimeChanges relating to runtime APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions