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

Ensure _localMatMdf is reset to false #3040

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

geomaster
Copy link
Contributor

@geomaster geomaster commented Oct 31, 2023

With efeb109, support for transform effects has been added, which required introducing another matrix on TransformElement to represent the final transform matrix including the effects. This matrix is denoted as localMat

If there are no transform effects, localMat is the same (referentially) as the existing transform matrix (mat). Otherwise, it's calculated by composing the transform effects and then composing that with the "old" transform matrix.

Alongside localMat, a _localMatMdf member is introduced, which tracks whether the local matrix was modified since its last commit to the DOM, analogously to _matMdf.

Unfortunately, a logic bug introduced by efeb109 meant that, in the absence of transform effects, _localMatMdf was latched to true, i.e. no code path would ever be able to reset it to false after it was once set to true (e.g. as a result of the matrix being animated).

This causes a serious performance regression, since all matrices that once had _matMdf set to true will keep being updated in the DOM every frame, causing costly full style recalculations.

Fix by forcing _matMdf and _localMatMdf to be equivalent in the case of no transform effects, just as mat and localMat are referentially equal. In the case of >0 transform effects, the custom logic in renderLocalTransform() will take over and compute _localMatMdf separately from and based on _matMdf.

Affected versions: [email protected] to latest

With efeb109, support for transform effects has been added, which
required introducing another matrix on `TransformElement` to represent
the final transform matrix including the effects. This matrix is denoted
as `localMat`

If there are no transform effects, `localMat` is the same
(referentially) as the existing transform matrix (`mat`). Otherwise,
it's calculated by composing the transform effects and then composing
that with the "old" transform matrix.

Alongside `localMat`, a `_localMatMdf` member is introduced, which
tracks whether the local matrix was modified since its last commit to
the DOM, analogously to `_matMdf`.

Unfortunately, a logic bug introduced by efeb109 meant that, in the
absence of transform effects, `_localMatMdf` was latched to `true`,
i.e. no code path would ever be able to reset it to `false` after it was
once set to `true` (e.g. as a result of the matrix being animated).

This causes a serious performance regression, since all matrices that
once had `_matMdf` set to `true` will keep being updated in the DOM
every frame, causing costly full style recalculations.

Fix by forcing `_matMdf` and `_localMatMdf` to be equivalent in the
case of no transform effects, just as `mat` and `localMat` are
referentially equal. In the case of >0 transform effects, the custom
logic in `renderLocalTransform()` will take over and compute
`_localMatMdf` separately from and based on `_matMdf`.
@AliT3 AliT3 merged commit e53f078 into airbnb:master Mar 19, 2024
1 check failed
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.

2 participants