Bug 170155 - Animated SVG images are not paused when outside viewport
Summary: Animated SVG images are not paused when outside viewport
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on: 171243
Blocks: 170043
  Show dependency treegraph
 
Reported: 2017-03-27 18:33 PDT by Chris Dumez
Modified: 2017-04-24 12:55 PDT (History)
9 users (show)

See Also:


Attachments
WIP Patch (22.00 KB, patch)
2017-03-27 19:56 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (22.04 KB, patch)
2017-03-27 20:09 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-elcapitan (1.06 MB, application/zip)
2017-03-28 01:59 PDT, Build Bot
no flags Details
Patch (29.70 KB, patch)
2017-03-28 12:09 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (30.51 KB, patch)
2017-03-28 14:08 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.