-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
High CPU usage #125
Comments
That's interesting. How did you benchmark that? |
You can simply open the home page of this library (http://danilowoz.com/create-content-loader), then check the chrome's Task Manager., you'll see the cpu usage monitor. Now I am pretty sure it's caused by the svg animation ( if I set |
Thanks, I got your point. I can see that animations are taking significant CPU time (34-38%) at my system. I think that this is the issue with animations in general, as this chromium bug. However, we'll look into it and try to figure out a way to reduce CPU usage. |
Thanks, it's not a big problem cause the content loader won't last for a long time, but fix it will be perfect. |
I've tried some alternatives approaches and I reached these results, but I'm not sure if I should forward in one of these or wait for a chrome fix:
<linearGradient id={idGradient} x1="-100%">
<stop
offset="0%"
stopColor={primaryColor}
stopOpacity={primaryOpacity}
/>
<stop
offset="50%"
stopColor={secondaryColor}
stopOpacity={secondaryOpacity}
/>
<stop
offset="100%"
stopColor={primaryColor}
stopOpacity={primaryOpacity}
/>
<animate
attributeName="x1"
from="-100%"
to="100%"
dur={`${speed}s`}
repeatCount="indefinite"
/>
</linearGradient>
|
Is there a way to push SVG animations to the GPU? |
We're seeing similarly high CPU usage when animate=true for React Native as well. |
I'm seeing similar results regarding my CPU usage as well. I'm using React (for the web) on development mode and for comparison, those are the CPU usage without and with FIY: I'm using |
Seems to have a huge perf hit on CPU danilowoz/react-content-loader#125
I actually have a huge CPU usage on this page https://danilowoz.com/create-content-loader/ but it's still close to 0 on this codesandbox https://codesandbox.io/s/6x2414oqln. |
See the following proposal @danilowoz. The essence is to use SVG Tested in latest firefox, low CPU usage. Didn't check for compatibility with other browsers. SVG:
CSS:
Have a nice day! |
This reporting in Chromium might help: https://bugs.chromium.org/p/chromium/issues/detail?id=1141881 |
Also most likely related to this - when using Detox (React Native) to test, tests just hang whenever the content loader is present. Might be something to do with how Animate lib is interacted with, maybe some unresolved promise. If I set animate={false} it works well. |
I did`t research much this topic, but can add when I trying to run tests - every time snapshot are updated, without any changes in spec file, and every time updates below property of ( symbols in **). Test passes very long time, and seems like an infinity loop, one time I even got error with full memory.
|
@AND-GORNIY regarding the Make sense? |
Ref: high CPU usage that may be responsible for the crash on Android: danilowoz/react-content-loader#125
Ref: high CPU usage that may be responsible for the crash on Android: danilowoz/react-content-loader#125
Ref: high CPU usage that may be responsible for the crash on Android: danilowoz/react-content-loader#125
Ref: high CPU usage that may be responsible for the crash on Android: danilowoz/react-content-loader#125
Found an interesting sort of solution to this problem: "As with the hero of any story, however, there must be a fall from grace. For animated SVGs, this fall occurs in CPU usage. The inclusion of just a few on a webpage can cause the CPU usage of a browser to jump by several tens of percentage points. Viewing such a page on even modern laptops will cause the machine to whirr like it’s trying to take flight and heat up like a bacon griddle. Fortunately, redemption for our hero comes easily and quickly in the form of CSS hardware acceleration. If you’re unfamiliar with the concept, the idea is to give a troublesome element the style Worked well for me, reduced the max workload experienced from 40-50% to an average of 20-30% (still a lot, but an improvement). |
I fixed this by re-implementing the loader to clip a div instead of a rect. I also had to rely on animating opacity instead of backgroundColor/fill. |
As shown in the above image the home page's cpu usage is always more than 40% and also more 20% in my app. I think this is abnormal, please confirm whether it is a bug or the normal phenomenon?
The text was updated successfully, but these errors were encountered: