Skip to content

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Sep 2, 2025

Safari still calculates rendering for animations that are set with animateTransform, even if they aren't being displayed (svg or parent is hidden). This causes performance issues on older devices.

We work around this by manually pausing or unpausing the svg depending on whether it's displayed.

https://bugs.webkit.org/show_bug.cgi?id=298217
closes #1322

before after
Screenshot 2025-09-02 at 10 21 38 Screenshot 2025-09-02 at 10 21 23

Safari still calculates rendering for animations that are set with animateTransform, even if they aren't being displayed (svg or parent is `hidden`). This causes performance issues on older devices.

We work around this by manually pausing or unpausing the svg depending on whether it's displayed.

https://bugs.webkit.org/show_bug.cgi?id=298217
closes #1322
@Haroenv Haroenv requested review from a team, aymeric-giraudet and shaejaz and removed request for a team September 2, 2025 08:32
Copy link

codesandbox-ci bot commented Sep 2, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0b4b2a4:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

Haroenv added a commit to algolia/instantsearch that referenced this pull request Sep 2, 2025
In Safari, an animation with animateTransform being in the dom (even if hidden) will cause a style recalculation on every frame. This also causes needless processor usage, and slowdown on old devices.

This PR solves this issue in instantsearch by preventing rendering of the loading icon if it shouldn't be displayed.

- react: remove rendering
- js: remove rendering
- vue: already not rendering

ref: https://bugs.webkit.org/show_bug.cgi?id=298217
ref: algolia/autocomplete#1322
ref: algolia/autocomplete#1323
@Haroenv Haroenv merged commit 075ab98 into next Sep 2, 2025
10 checks passed
@Haroenv Haroenv deleted the fix/pause-animations branch September 2, 2025 15:40
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

Successfully merging this pull request may close these issues.

Continuous style recalculations and high CPU usage in Safari
2 participants