Skip to content

Conversation

thePunderWoman
Copy link
Contributor

@thePunderWoman thePunderWoman commented Aug 28, 2025

This fixes several issues and removes the need to have a feature to enable the animation removal element registry. Instead we track the animations on the LView itself, and we can deal with dispatching them at the right time before cleanups and destroy is called.

fixes: #63391
fixes: #63388
fixes: #63369

@thePunderWoman thePunderWoman added area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release labels Aug 28, 2025
@ngbot ngbot bot modified the milestone: Backlog Aug 28, 2025
@thePunderWoman thePunderWoman force-pushed the parallel-animation branch 8 times, most recently from 9a58c72 to 786cab0 Compare August 29, 2025 10:17
@kukjevov
Copy link
Contributor

kukjevov commented Sep 2, 2025

Anything new here ? :)

@thePunderWoman thePunderWoman force-pushed the parallel-animation branch 3 times, most recently from 8c21526 to 9d19ff0 Compare September 5, 2025 19:06
@thePunderWoman thePunderWoman added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 5, 2025
@thePunderWoman thePunderWoman marked this pull request as ready for review September 5, 2025 19:33
duration: number;
}

export interface AnimationLViewData {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider making this a monomorphic object, i.e. make all props required (and create objects using a single factory function).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elements may not have both enter and leave animations. This was to save on allocation of memory for the arrays in that case. Do you think the monomorphic object benefits outweigh the memory usage?

Copy link
Member

@JoostK JoostK Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good judgement about the memory effect this may have, so the only way to tell is through profiling (but we may not have a reasonable test corpus?). Primarily runEnterAnimations runs in a hot code path, all others are only accessed during the creation phase or view destruction so would benefit less from monomorphic accesses.

For the full picture, there would be up to four hidden classes currently, for the following transitions:

  • enter > running
  • leave > running
  • enter > leave > running
  • leave > enter > running

And V8 uses—at least back in the day, if I'm not mistaken—4 different hidden classes as threshold for polymorphic vs megamorphic so there's still ICs for the property accesses, they aren't deoptimized entirely like they would if it were megamorphic.

That is to say I don't really know if it's worth the trade-off, and since we're not megamorphic it may be okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also worth noting this is just a first go at this optimization. We'll likely move these things out of the LView slot in a follow up refactor to make it even more optimized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoostK It's also worth noting that enter does not have a running state that is tracked. Enter is triggered and will get cleared out immediately. Running only has any usefulness when leave animations are present. The running field would only ever be populated once leave animations are actually triggered. So really there's possibly less states.

@thePunderWoman thePunderWoman force-pushed the parallel-animation branch 4 times, most recently from 84d2dc6 to 08af031 Compare September 5, 2025 20:55
This tracks the enter and leave functions in the LView to be executed at a safe time for change detection.
This updates the enter and leave logic to use the stored LView data to dispatch the enter and leave animations at the right points in the lifecycle. This should fix issues with signals not being available yet, parallel animations, and also eliminate the need for the element registry.

fixes: angular#63391
fixes: angular#63388
fixes: angular#63369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release
Projects
None yet
3 participants