Move per-element image animation state to ElementAnimations [chromium/src : main]

0 views
Skip to first unread message

Seokho Song (Gerrit)

unread,
May 14, 2026, 3:24:34 AM (24 hours ago) May 14
to Robert Flack, Florin Malita, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Olga Gerchikov, Stephen Chenney, Menard, Alexis, android-bu...@system.gserviceaccount.com, blink-re...@chromium.org, blink-revie...@chromium.org, drott+bl...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org, blink-reviews-p...@chromium.org, blink-...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, apavlo...@chromium.org, fmalit...@chromium.org, blink-rev...@chromium.org
Attention needed from Florin Malita and Robert Flack

Seokho Song voted and added 4 comments

Votes added by Seokho Song

Commit-Queue+1

4 comments

Patchset-level comments
File-level comment, Patchset 23:
Robert Flack . unresolved

I'm not sure I understand all of indirection going on in this patch. I can see that when we have a value that is not normal, we need to track some information for that element - but the purpose of using ElementAnimations was to have element associated data - it seems like we're storing this data on the bitmap though with a possible risk of never erasing it.

Seokho Song

the informations are moved to ElementAnimation.

File third_party/blink/renderer/core/dom/element.cc
Line 5569, Patchset 23: if (RuntimeEnabledFeatures::CSSImageAnimationEnabled()) {
Robert Flack . resolved

These calls to clear don't need to be flag guarded since we would not add any image animations if the flag wasn't enabled so the clear would be a no-op.

Seokho Song

Done

File third_party/blink/renderer/platform/graphics/bitmap_image.cc
Line 423, Patchset 23: image_animation_map_.find(image_node_animation_info->node_id);
Robert Flack . unresolved

Why is image_animation_map_ a map of NodeId to ImageAnimationData on BitmapImage rather than storing ImageAnimationData on ElementAnimations? It seems like if we stored the animation data on ElementAnimations then there would be no risk of the data persisting when the element is detached or memory leaks by not removing entries.

Seokho Song

Ahh!! Yes. That's a good idea.
We don't need to store it in `bitmap_image`. We can do this by taking the paint id and sync sequence from the Painter.

Line 498, Patchset 23: image_animation_map_.erase(animation_data_it);
Robert Flack . unresolved

It seems like this is the only call to erase the image animation data state, but what happens if the node is detached from the dom or becomes display none, we would never call PaintImageForCurrentFrameWithInfo right?

Seokho Song

Yes. Here is some context:
1. The first issue was raised on [this CL](https://chromium-review.googlesource.com/c/chromium/src/+/7596743/comment/fae52653_f5d32ce5/) where we decided to defer the erase logic.
2. And the discussions continued across WIP CLs. CLs ([First](https://chromium-review.googlesource.com/c/chromium/src/+/7692355) -> [Second](https://chromium-review.googlesource.com/c/chromium/src/+/7727509)).

So the original plan was to remove the entry data (similar with the first one) after landing this CL.
However, since this CL now changed the approach to store the data in `ElementAnimation` rather than `bitmap_image`, a further patch is no longer needed.

Open in Gerrit

Related details

Attention is currently required from:
  • Florin Malita
  • Robert Flack
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Iff5306cafb4a13ab46783fe29cd56838ee3789f0
Gerrit-Change-Number: 7771511
Gerrit-PatchSet: 30
Gerrit-Owner: Seokho Song <seo...@chromium.org>
Gerrit-Reviewer: Florin Malita <fma...@chromium.org>
Gerrit-Reviewer: Robert Flack <fla...@chromium.org>
Gerrit-Reviewer: Seokho Song <seo...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Robert Flack <fla...@chromium.org>
Gerrit-Attention: Florin Malita <fma...@chromium.org>
Gerrit-Comment-Date: Thu, 14 May 2026 07:24:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Robert Flack <fla...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Robert Flack (Gerrit)

unread,
May 14, 2026, 4:48:13 PM (10 hours ago) May 14
to Seokho Song, Florin Malita, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Olga Gerchikov, Stephen Chenney, Menard, Alexis, android-bu...@system.gserviceaccount.com, blink-re...@chromium.org, blink-revie...@chromium.org, drott+bl...@chromium.org, blink-re...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org, blink-reviews-p...@chromium.org, blink-...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, apavlo...@chromium.org, fmalit...@chromium.org, blink-rev...@chromium.org
Attention needed from Florin Malita and Seokho Song

Robert Flack added 6 comments

File third_party/blink/renderer/core/animation/element_animations.h
Line 210, Patchset 30 (Latest): image_animation_data_;
Robert Flack . unresolved

Much like we have wrapped up the css_animations_ into a separate CssAnimations class, would you mind creating a css_image_animations_ to encapsulate additional data members and functionality? I'm recommending css be in the name since it's driven by a css property and has the same lifetime expectations as css animations.

You can directly expose the inner class similar to how we do for CssAnimations():
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/animation/element_animations.h;l=96 so that you don't need forwarding methods.

File third_party/blink/renderer/core/dom/element.cc
Line 4478, Patchset 30 (Latest): element_animations->ClearPreviousImageAnimation();
Robert Flack . unresolved

We should clear everything about the CssImageAnimations - i.e. the entire map - not just the previous value.

File third_party/blink/renderer/core/paint/image_painter.cc
Line 304, Patchset 30 (Latest): image_animation);
Robert Flack . unresolved

Rather than updating element animations here, i think it might be cleaner to provide The new CssImageAnimations class which could implement an interface in third_party/blink/renderer/platform/graphics/ that provides the necessary methods to check whether we have data for a given bitmap and allows updating that data.

This way we don't have to even construct ImageNodeAnimationInfo for the normal case, nor do we have to update it at a distance from where the logic to do the update is performed.

File third_party/blink/renderer/platform/graphics/bitmap_image.cc
Line 421, Patchset 30 (Latest): image_node_animation_info->previous_image_animation;
Robert Flack . unresolved

I don't understand why we need to use the previous image animation value. We should be storing in the ImageAnimationData what the previous sequence was.

It seems like this should be sufficient to determine what we need to do here, e.g. something like this:
```c++
switch (image_animation) {
kNormal:
// Set stored sequence id to 0.
kRunning:
// If !has_previous_animation_data, then set sequence id to
// image_node_animation_info->non_normal_sequence_id + 1
// Otherwise, it will continue to use the sequence that was set.
kPaused:
// If !has_previous_animation_data, or current sequence is 0,
// then set sequence id to
// image_node_animation_info->non_normal_sequence_id + 1
kStopped:
// Remove from map
}
```
Line 423, Patchset 30 (Latest): previous_image_animation.has_value();
Robert Flack . unresolved

Rather than using the previous image animation value, it seems like we should use whether there was an ImageAnimationData in the map on ElementAnimations.

Line 498, Patchset 23: image_animation_map_.erase(animation_data_it);
Robert Flack . unresolved

It seems like this is the only call to erase the image animation data state, but what happens if the node is detached from the dom or becomes display none, we would never call PaintImageForCurrentFrameWithInfo right?

Seokho Song

Yes. Here is some context:
1. The first issue was raised on [this CL](https://chromium-review.googlesource.com/c/chromium/src/+/7596743/comment/fae52653_f5d32ce5/) where we decided to defer the erase logic.
2. And the discussions continued across WIP CLs. CLs ([First](https://chromium-review.googlesource.com/c/chromium/src/+/7692355) -> [Second](https://chromium-review.googlesource.com/c/chromium/src/+/7727509)).

So the original plan was to remove the entry data (similar with the first one) after landing this CL.
However, since this CL now changed the approach to store the data in `ElementAnimation` rather than `bitmap_image`, a further patch is no longer needed.

Robert Flack

Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Florin Malita
  • Seokho Song
Gerrit-Attention: Florin Malita <fma...@chromium.org>
Gerrit-Attention: Seokho Song <seo...@chromium.org>
Gerrit-Comment-Date: Thu, 14 May 2026 20:48:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Robert Flack <fla...@chromium.org>
Comment-In-Reply-To: Seokho Song <seo...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages