New issue
Advanced search Search tips

Issue 706152 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Pause SVG image animations when there are no clients / no clients in the visual viewport

Project Member Reported by pdr@chromium.org, Mar 28 2017

Issue description

WebKit just landed an interesting patch to pause SVG image animations when the SVG image is not used or is not in the viewport: https://bugs.webkit.org/show_bug.cgi?id=170155.

They said this affects Yahoo.com.
 

Comment 1 by f...@opera.com, Mar 28 2017

This sounds very much like what 5ad4faa93d2554ffab7f72a992adbeffa8796f94 implemented. The "not in viewport" bit ought to be Image subclass agnostic. (Does PaintInvalidationDelayedFull cover that well enough?)
I think we can apply the same thing already done for LayoutBox and background-image
of LayoutBox that works for animated GIFs.

Animated GIF throttling works like this:

1. A timer fires from the image saying that the image has a new frame to draw
2. LayoutImage (or LayoutBox) hears that and invalidates paint on itself.
3. In the next document lifecycle, the Layout{Image,Box} paints itself. As part of
this it asks the image to paint itself into the display list.
4. When painting itself, BitmapImage::draw() will paint itself, then call
BitmapImpage::startAnimation() on itself. This sets off a timer to go back to step 1.

Our code short-circuits this cycle for animated GIFs by issuing a "delayed" paint
invalidation at step 2 when we notice that the GIF is not visible (by calling
LayoutBox::intersectsVisibleViewport). If that returns true, we upgrade to a non-delayed
invalidation for that frame, and otherwise issue an invalidation to be checked again
for paint invalidation in the next frame.

It appears that SVGImage uses the same pattern as BitmapImage, so therefore we can do the
same for SVG images. In fact, I'm not sure why it doesn't work already. Is the ImageResource not
returning maybeAnimated in invalidation in LayoutImage?

fs@ would you like to take a look?

Comment 3 by f...@opera.com, Mar 28 2017

Owner: f...@opera.com
Status: Assigned (was: Available)
Adding to backlog.

Comment 4 by f...@opera.com, Mar 29 2017

Looks like Image::maybeAnimated() isn't even overridden for SVGImage. Doing that should be easy enough since we already have essentially the same predicate already (from an old version of the same method even I think...)
Labels: PaintTeamTriaged-20170328 BugSource-Team

Comment 6 by f...@opera.com, Mar 30 2017

Summary: Pause SVG image animations when there are no clients / no clients in the visual viewport (was: Pause SVG image animations when there are no clients)
Project Member

Comment 7 by bugdroid1@chromium.org, Mar 31 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bb03bc3127de97898e62323b12cd2997267cfd5a

commit bb03bc3127de97898e62323b12cd2997267cfd5a
Author: fs <fs@opera.com>
Date: Fri Mar 31 10:38:13 2017

Implement Image::maybeAnimated for SVGImage

This CL renames SVGImage::hasAnimations to maybeAnimated, overriding
the implementation from the base class (Image.) The old method matches
the new one in certainty of the reply, and allows SVGImages to be paused
when being scrolled out of view etc.

BUG= 706152 

Review-Url: https://codereview.chromium.org/2783133002
Cr-Commit-Position: refs/heads/master@{#461094}

[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-background-offscreen-expected.txt
[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-background-offscreen.html
[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-offscreen-expected.txt
[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-offscreen.html
[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-transformed-offscreen-expected.txt
[add] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/LayoutTests/paint/invalidation/svg/animated-svg-as-image-transformed-offscreen.html
[modify] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
[modify] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/Source/core/svg/graphics/SVGImage.h
[modify] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/Source/core/svg/graphics/SVGImageChromeClient.cpp
[modify] https://crrev.com/bb03bc3127de97898e62323b12cd2997267cfd5a/third_party/WebKit/Source/core/svg/graphics/SVGImageTest.cpp

Comment 8 by f...@opera.com, Apr 3 2017

Status: Fixed (was: Assigned)
I think all components should be there now.

Sign in to add a comment