paper-ripple icon indicating copy to clipboard operation
paper-ripple copied to clipboard

PERF: paper-ripple sets transform every frame instead of using accelerated animation

Open ebidel opened this issue 9 years ago • 10 comments

From @danakj on December 18, 2015 23:3

Rather than setting a new scale every frame, the effect would achieve better performance across browsers by using an accelerated animation. This would provide the browser with more hints to avoid re-raster on every frame.

The bug occurs in the drawRipple method https://code.google.com/p/chromium/codesearch#chromium/src/third_party/catapult/third_party/polymer/components/paper-ripple/paper-ripple.html&l=190

It can be reproduced by paper-button/demo.html, which is run by telemetry bots as per https://code.google.com/p/chromium/issues/detail?id=563504#c16

See more details here: https://code.google.com/p/chromium/issues/detail?id=563504#c18

Copied from original issue: Polymer/polymer#3219

ebidel avatar Jan 03 '16 14:01 ebidel

maybe @cdata @valdrinkoshi @notwaldorf could take a look?

ebidel avatar Jan 03 '16 14:01 ebidel

Also note previous discussion https://github.com/Polymer/paper-ripple/issues/10. Looks great on desktop, although on Android (Zenfone2) the ripple is very janky. Needs much more butter.

Aside: That being said, I'm truly blown away (figuratively) by how smooth iron-animated pages and iron-list are on mobile. In a ~1.2 MB app (html & js, pre-gzip), this is one of the few areas that gives away that it could be running non-native. So kudos to the team for that and all the hard work.

zmoshansky avatar Feb 04 '16 00:02 zmoshansky

ping

ebidel avatar Mar 10 '16 23:03 ebidel

I'll jump the bandwagon and ping again. Any movement? Would a PR be welcome, or would you prefer doing this in house?

kristfal avatar May 25 '16 12:05 kristfal

I think a PR would be welcome at this point :)

ebidel avatar May 25 '16 13:05 ebidel

@tjsavage

danbeam avatar Nov 30 '16 00:11 danbeam

/cc @frankiefu as well

some ideas:

  1. detect whether Element#animate() exists and use it
  2. set less .style properties (i.e. only set a 2D webkitTransform in Safari and skip duplicative .style.transform which was unprefixed in Chrome 36)
  3. set .style values to the destination radius and rely on transition or @keyframes rather than continually using requestAnimationFrame (and canceling on up by changing .style.animationName or the .style.transition properties, possibly polyfilling transitionend for cancels)

danbeam avatar Nov 30 '16 01:11 danbeam

Any update on this?

LarsDenBakker avatar Jun 24 '17 09:06 LarsDenBakker

I haven't been pushing on this hard because Chrome wrote it's own ripple via Web Animations API (i.e. Element#animate). https://cs.chromium.org/chromium/src/third_party/polymer/v1_0/components-chromium/paper-ripple/

@blasten wrote a few branches with faster ripples which might actually work in other browsers: https://github.com/PolymerElements/paper-ripple/compare/fast-ripple https://github.com/PolymerElements/paper-ripple/compare/fast-ripple-2

danbeam avatar Jun 26 '17 06:06 danbeam

That's useful information, thanks!

LarsDenBakker avatar Jun 26 '17 07:06 LarsDenBakker