Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf Audit #1

Open
paulirish opened this issue Apr 10, 2016 · 11 comments
Open

Perf Audit #1

paulirish opened this issue Apr 10, 2016 · 11 comments

Comments

@paulirish
Copy link

Going to dump my notes in here an edit as I go.

Starting with the master branch as that seems preferred for ergonomics.

image

Looks like a case of heavy rasterization. SVG gets this a lot.

Let's see what we can do!

@paulirish
Copy link
Author

I applied some absolute positioning to visually distinguish things with paint flashing on.

image

Okay so the SVG is rasterizing each frame. The DIV only rasterizes at the toggle.

Still I think the DIV shouldn't need to rasterize much at all. Curious if we can get rid of that.

(That said, the SVG rasterization is whats really important)

@paulirish
Copy link
Author

Nuking the raster costs on the avatar div

will-change: transform on both the div.avatar and the .avatar-box:before take care of the rasterization flashes: Woo!

image

Before and After

We're looking at the exact same flip here. That raster cost in the middle is gone.

image

@paulirish
Copy link
Author

raster costs of the SVG

Setting display: none !important; on the avatar, now that it's sorted, so we can look at the SVG all alone.

Yup. It's just hitting a lot of rasterization costs on every frame.

image

Damn. using the animation editor is a nice way to diagnose the animation itself. Pause and scrubber dragging totally kick ass:

image


Now, re-reading the project readme. The technique explored in "reverse" is my best guess for what's going have the most promise. Going to move over there.

@paulirish
Copy link
Author

Splitting apart the SVG layers

Using the reverse branch, I again see that raster costs of the SVG during its path animation are the problem. I was curious if we could reduce that cost by getting rid of some extra stuff. So I tried splitting the white circle in the middle of the SVG out to a static SVG that doesn't change:

image

Comparing it to before, the rasterization costs seem much smaller.
image

NEVERMIND. Put back the white circle and the raster costs are still down. Maybe it was something else I did.

@paulirish
Copy link
Author

Oh reverse is just much less rasterization than master was. That's all. :) Nice job.

@paulirish
Copy link
Author

reverse on Android

Things are looking fine on desktop, even with CPU throttling, so over to remote debugging my nexus 5X

image

Raster time is bigger here. ~12ms per frame. With that time, it's possible we could still hit 60fps, but it'd be tight.

Unfortunately, the GPU is the bottleneck here. Bigtime.

Curious about Ganesh in this case....

@paulirish
Copy link
Author

Ganesh & GPU

Ganesh is on.. I tried turning it off, but there's not a sigificant difference either way.

GPU is the bottleneck for sure.

Tracing to see if that provides any more details:

image

No insights here. Just taking time flushing all the work to the GPU each frame.

@paulirish
Copy link
Author

I've exhausted my own techniques on this one.

cc @progers @fregu In case you guys are interested in a a well-optimized SVG animation that just isn't good enough. See the readme at https://github.com/kdzwinel/progress-bar-animation for details.

Repro:

  1. Open http://rawgit.com/kdzwinel/progress-bar-animation/reverse/index.html on mobile
  2. See that raster + GPU costs are a bit costly. Main thread compositing is also reliably expensive.
  3. Try to reduce those costs.

@nathanmarks
Copy link

@paulirish this is very problematic with material design spinners when used in an application transition state. Can we expect any improvements here in the medium term?

@tigt
Copy link

tigt commented Nov 2, 2016

@paulirish From what's public, Ganesh appears not to work at all when some SVG is involved:

Note that GPU rasterization can get vetoed based on the content itself. For example, if page contains many SVGs with non-convex paths (common for SVG icons), GPU rasterization may get disabled for that page load.

@progers
Copy link

progers commented Nov 2, 2016

It's not a complete veto for svg. The heuristic is based on the absolute number of non-convex paths.

There are two ongoing projects in progress now that will likely remove this heuristic/veto soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants