Bug 170155

Summary: Animated SVG images are not paused when outside viewport
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: SVGAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, buildbot, kling, koivisto, rniwa, sabouhallawa, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=170335
Bug Depends on: 171243    
Bug Blocks: 170043    
Attachments:
Description Flags
WIP Patch
none
WIP Patch
none
Archive of layout-test-results from ews103 for mac-elcapitan
none
Patch
none
Patch none

Description Chris Dumez 2017-03-27 18:33:59 PDT
Animated SVG images are not paused when outside viewport.
Comment 1 Radar WebKit Bug Importer 2017-03-27 18:34:53 PDT
<rdar://problem/31288893>
Comment 2 Chris Dumez 2017-03-27 19:56:26 PDT
Created attachment 305545 [details]
WIP Patch
Comment 3 Chris Dumez 2017-03-27 20:09:18 PDT
Created attachment 305547 [details]
WIP Patch
Comment 4 Build Bot 2017-03-28 01:59:18 PDT
Comment on attachment 305547 [details]
WIP Patch

Attachment 305547 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3425668

New failing tests:
svg/animations/animated-svg-image-outside-viewport-paused.html
svg/animations/animated-svg-image-removed-from-document-paused.html
Comment 5 Build Bot 2017-03-28 01:59:21 PDT
Created attachment 305574 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 6 Chris Dumez 2017-03-28 12:09:19 PDT
Created attachment 305620 [details]
Patch
Comment 7 Antti Koivisto 2017-03-28 13:44:54 PDT
Comment on attachment 305620 [details]
Patch

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

> Source/WebCore/loader/cache/CachedImage.cpp:121
> +    if (m_image)
> +        m_image->startAnimation();

It might be clearer if this was renamed to something like startAnimationIfNeeded() as it doesn't actually always start it.

> Source/WebCore/loader/cache/CachedImage.cpp:526
> +    bool shouldPauseAnimation = true;
> +
>      CachedResourceClientWalker<CachedImageClient> clientWalker(m_clients);
> -    while (CachedImageClient* client = clientWalker.next())
> -        client->newImageAnimationFrameAvailable(*this);
> +    while (CachedImageClient* client = clientWalker.next()) {
> +        bool canPause = false;
> +        client->newImageAnimationFrameAvailable(*this, canPause);

One bool would be enough (canPause could be moved outside the loop).

> Source/WebCore/rendering/RenderElement.cpp:1496
> +void RenderElement::newImageAnimationFrameAvailable(CachedImage& image, bool& canPause)

Another option would be to use an enum return value.

> Source/WebCore/rendering/RenderView.cpp:1402
> +        return Vector<CachedImage*>();

Are these CachedImages somehow guaranteed to stay alive?
Comment 8 Chris Dumez 2017-03-28 14:08:11 PDT
Created attachment 305639 [details]
Patch
Comment 9 Chris Dumez 2017-03-28 16:11:40 PDT
Comment on attachment 305639 [details]
Patch

Clearing flags on attachment: 305639

Committed r214503: <http://trac.webkit.org/changeset/214503>
Comment 10 Chris Dumez 2017-03-28 16:11:45 PDT
All reviewed patches have been landed.  Closing bug.