Bug 208079 - AnimationTimeline should not have multiple HashMaps with raw Element* keys
Summary: AnimationTimeline should not have multiple HashMaps with raw Element* keys
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-21 16:32 PST by Simon Fraser (smfr)
Modified: 2020-03-12 00:48 PDT (History)
16 users (show)

See Also:


Attachments
Patch (49.84 KB, patch)
2020-03-11 04:04 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (52.49 KB, patch)
2020-03-11 04:08 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (52.98 KB, patch)
2020-03-11 06:14 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (52.94 KB, patch)
2020-03-11 06:27 PDT, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (53.55 KB, patch)
2020-03-11 09:37 PDT, Antoine Quint
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2020-02-21 16:32:45 PST
We need to find a different solution to the 6 HashMaps that AnimationTimeline has. We have to consult each of them every time we remove an element.
Comment 1 Radar WebKit Bug Importer 2020-02-21 16:33:20 PST
<rdar://problem/59687906>
Comment 2 Ryosuke Niwa 2020-02-21 17:54:01 PST
We should probably move these data structures to hang off of ElementRareData. Create something like ElementAnimationRareData and then put it on ElementRareData.
Comment 3 Antoine Quint 2020-02-24 03:51:33 PST
I like Ryosuke's suggestion and will implement that.
Comment 4 Antoine Quint 2020-03-10 12:08:11 PDT
Should also make KeyframeEffectStack hang off that instead of ElementRareData directly.
Comment 5 Ryosuke Niwa 2020-03-10 22:40:04 PDT
(In reply to Antoine Quint from comment #4)
> Should also make KeyframeEffectStack hang off that instead of
> ElementRareData directly.

That would make most sense.
Comment 6 Antoine Quint 2020-03-11 04:04:19 PDT
Created attachment 393217 [details]
Patch
Comment 7 Antoine Quint 2020-03-11 04:08:00 PDT
Created attachment 393219 [details]
Patch
Comment 8 Antoine Quint 2020-03-11 06:14:18 PDT
Created attachment 393231 [details]
Patch
Comment 9 Antoine Quint 2020-03-11 06:27:35 PDT
Created attachment 393233 [details]
Patch
Comment 10 Simon Fraser (smfr) 2020-03-11 09:11:51 PDT
Comment on attachment 393233 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=393233&action=review

> Source/WebCore/dom/NodeRareData.h:262
> +        Animations = 1 << 14,

I think you missed the #if DUMP_NODE_STATISTICS code that uses this enum value.
Comment 11 Antoine Quint 2020-03-11 09:37:08 PDT
Created attachment 393252 [details]
Patch
Comment 12 Antoine Quint 2020-03-11 09:38:12 PDT
(In reply to Simon Fraser (smfr) from comment #10)
> Comment on attachment 393233 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=393233&action=review
> 
> > Source/WebCore/dom/NodeRareData.h:262
> > +        Animations = 1 << 14,
> 
> I think you missed the #if DUMP_NODE_STATISTICS code that uses this enum
> value.

I did! I added the required code in the newest patch.
Comment 13 Ryosuke Niwa 2020-03-11 13:15:30 PDT
Comment on attachment 393252 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=393252&action=review

> Source/WebCore/animation/AnimationTimeline.cpp:105
> +    if (is<CSSTransition>(animation) && downcast<CSSTransition>(animation).owningElement())
> +        element.transitions().add(&animation);

Should we check that the owning element is same as element here??

> Source/WebCore/animation/AnimationTimeline.cpp:107
> +    else if (is<CSSAnimation>(animation) && downcast<CSSAnimation>(animation).owningElement())
> +        element.cssAnimations().add(&animation);

Ditto.

> Source/WebCore/animation/ElementAnimationRareData.h:38
> +    WTF_MAKE_FAST_ALLOCATED;

Make this not copyable?

> Source/WebCore/dom/Element.h:496
> +    AnimationCollection& webAnimations();

Should we also forward declare AnimationCollection & CSSAnimationCollection?
Comment 14 Antoine Quint 2020-03-11 13:30:01 PDT
(In reply to Ryosuke Niwa from comment #13)
> Comment on attachment 393252 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=393252&action=review
> 
> > Source/WebCore/animation/AnimationTimeline.cpp:105
> > +    if (is<CSSTransition>(animation) && downcast<CSSTransition>(animation).owningElement())
> > +        element.transitions().add(&animation);
> 
> Should we check that the owning element is same as element here??

These should always be the same thing, so I'll add an ASSERT().

> > Source/WebCore/animation/AnimationTimeline.cpp:107
> > +    else if (is<CSSAnimation>(animation) && downcast<CSSAnimation>(animation).owningElement())
> > +        element.cssAnimations().add(&animation);
> 
> Ditto.

Will add an ASSERT().

> > Source/WebCore/animation/ElementAnimationRareData.h:38
> > +    WTF_MAKE_FAST_ALLOCATED;
> 
> Make this not copyable?

Will do.

> > Source/WebCore/dom/Element.h:496
> > +    AnimationCollection& webAnimations();
> 
> Should we also forward declare AnimationCollection & CSSAnimationCollection?

No, these come from `#include "WebAnimationTypes.h"`.
Comment 15 Antoine Quint 2020-03-12 00:48:15 PDT
Committed r258316: <https://trac.webkit.org/changeset/258316>
Comment 16 Antoine Quint 2020-03-12 00:48:52 PDT
(In reply to Ryosuke Niwa from comment #13)
> Comment on attachment 393252 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=393252&action=review
> 
> > Source/WebCore/animation/AnimationTimeline.cpp:105
> > +    if (is<CSSTransition>(animation) && downcast<CSSTransition>(animation).owningElement())
> > +        element.transitions().add(&animation);
> 
> Should we check that the owning element is same as element here??

In the end that was the right thing to do and I added the equality check in the commit.