Bug 205925 - [Web Animations] Stop creating CSS Animations for <noscript> elements
Summary: [Web Animations] Stop creating CSS Animations for <noscript> elements
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-08 06:57 PST by Antoine Quint
Modified: 2020-01-08 08:30 PST (History)
9 users (show)

See Also:


Attachments
Patch (7.54 KB, patch)
2020-01-08 07:02 PST, Antoine Quint
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2020-01-08 06:57:53 PST
[Web Animations] Stop creating CSS Animations for <noscript> elements
Comment 1 Antoine Quint 2020-01-08 07:02:15 PST
Created attachment 387103 [details]
Patch
Comment 2 Antoine Quint 2020-01-08 07:02:20 PST
<rdar://problem/58158479>
Comment 3 Antti Koivisto 2020-01-08 07:41:23 PST
Comment on attachment 387103 [details]
Patch

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

> Source/WebCore/ChangeLog:16
> +        It makes no sense to create CSS Animations for a <noscript> element and it has the side effect of potential crashes.
> +        Indeed, AnimationTimeline::updateCSSAnimationsForElement() may be called without a currentStyle and so we never have
> +        a list of previously-applied animations to compare to the list of animations in afterChangeStyle. So on each call we
> +        end up creating a new CSSAnimation and the previous animation for the same name is never explicitly removed from the
> +        effect stack and is eventually destroyed and the WeakPtr for it in the stack ends up being null, which would cause a
> +        crash under KeyframeEffectStack::ensureEffectsAreSorted().

You'll should add some other defense against this in animation code too as this patch likely doesn't cover all the paths where this can happen.

> Source/WebCore/html/HTMLElement.cpp:736
> -bool HTMLElement::rendererIsNeeded(const RenderStyle& style)
> +bool HTMLElement::rendererIsEverNeeded()

You can also switch HTMLInputElement::rendererIsNeeded to rendererIsEverNeeded, maybe others. Please check, they can probably all be used to get this crash.
Comment 4 Antti Koivisto 2020-01-08 08:04:24 PST
In fact most rendererIsNeeded functions can be turned into rendererIsEverNeeded. 

Doesn't need to be done in this patch though.
Comment 5 Antoine Quint 2020-01-08 08:27:49 PST
(In reply to Antti Koivisto from comment #3)
> Comment on attachment 387103 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=387103&action=review
> 
> > Source/WebCore/ChangeLog:16
> > +        It makes no sense to create CSS Animations for a <noscript> element and it has the side effect of potential crashes.
> > +        Indeed, AnimationTimeline::updateCSSAnimationsForElement() may be called without a currentStyle and so we never have
> > +        a list of previously-applied animations to compare to the list of animations in afterChangeStyle. So on each call we
> > +        end up creating a new CSSAnimation and the previous animation for the same name is never explicitly removed from the
> > +        effect stack and is eventually destroyed and the WeakPtr for it in the stack ends up being null, which would cause a
> > +        crash under KeyframeEffectStack::ensureEffectsAreSorted().
> 
> You'll should add some other defense against this in animation code too as
> this patch likely doesn't cover all the paths where this can happen.

It's more than a defense that is needed, the problem is that `AnimationTimeline` doesn't know to expect several CSS Animations with the same animation-name. I will address this as part of a different bug as soon as possible. I raised https://bugs.webkit.org/show_bug.cgi?id=205928.

> > Source/WebCore/html/HTMLElement.cpp:736
> > -bool HTMLElement::rendererIsNeeded(const RenderStyle& style)
> > +bool HTMLElement::rendererIsEverNeeded()
> 
> You can also switch HTMLInputElement::rendererIsNeeded to
> rendererIsEverNeeded, maybe others. Please check, they can probably all be
> used to get this crash.

I will add more rendererIsNeeded overrides in a followup, I raised
Comment 6 Antoine Quint 2020-01-08 08:28:20 PST
(In reply to Antoine Quint from comment #5)
> I will add more rendererIsNeeded overrides in a followup, I raisedhttps://bugs.webkit.org/show_bug.cgi?id=205929
Comment 7 Antoine Quint 2020-01-08 08:30:49 PST
Committed r254201: <https://trac.webkit.org/changeset/254201>