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
Decrease resource usage of CSS animations #2021
Conversation
f307582
to
9efd346
Compare
I think Firefox always use GPU, if it is available. Did you test it on other combinations of OSes and browsers? |
|
There is a mix of comments/articles on the internet saying opposite thinks about using CSS to trigger GPU rendering like this. I'm not sure which one is right. |
9efd346
to
33d566f
Compare
Yes, the solution with the transformation is weird. I just got it to work with the |
As I said, I'm not sure, but this version looks better. I like to get input from others before making a decision. Perhaps someone has a better understanding of these optimizations. |
BTW the issue here is that the animation is NOT using CSS properties which are offloaded to the GPU (border-color). I'd just change the animation effect, personally. |
We know what the color will be when at both ends: @keyframes warningPulse {
0% {
border-color: #71480a;
}
50% {
border-color: #f89201;
}
100% {
border-color: #71480a;
}
}
.box-warning {
animation: 3s infinite warningPulse;
} Could you try this @Iksas ? |
With these changes, both CPU and GPU are running at about 80%. So it's a bit better than with transparency, but not really where it should be. |
Would it be acceptable to reduce the FPS of the CSS animation? When limiting it to 20fps, the GPU usage drops to only 4% in Firefox / 10% in Safari:
(30 steps * 2 transitions / 3 seconds = 20fps) When the |
Safari is basically Internet Explorer these days... |
Yeah, I think so |
baa8e7c
to
1f67c23
Compare
Signed-off-by: Iksas <Iksas@users.noreply.github.com>
1f67c23
to
3691701
Compare
Signed-off-by: Iksas <Iksas@users.noreply.github.com>
@Iksas do you still have more to add to this, or is it in draft for another reason? |
I'm still working on this at the moment. I just fixed one last bug (hopefully), and still have to test everything after that. |
Just a note: This new fix is changing HTML and JS bits for all themes. Was this tested for all themes, with all main browsers? |
PS: I can't test this at least until tomorrow at night. |
By limiting the frame rate to 10fps while adding some pseudo elements, and animating only their opacity instead of RGB values, the CPU usage could be reduced by over 90% for some animations. However I understand that such an amount of changes might not be worth the improvement. For example, I used a Using this technique in the red update notification reduces CPU usage by about 50% on the same frame rate: If the changes are too much, reducing the frame rate alone could still improve the efficiency quite a bit with minimal changes. While testing, I couldn't perceive any stuttering for frame rates as low as 10fps (only color changes). Of course, this PR is just a suggestion. I just wanted to see what's possible, now it's up to the team ;) I have tested this in Firefox, Chromium and Safari. Later today, I will perform final tests, after which I will remove the draft status. |
27ddc2a
to
a5291a1
Compare
I took a quick test. I think I found 2 problems:
|
Thanks, I will take a look at this. |
Yes. The current behavior is to show the message only when the checkbox is activated. In my test, the checkbox started deactivated (and no message). If you remove the |
On more thing: I don't know if this improves something for the |
925f1fa
to
d225748
Compare
Both bugs have been fixed now. The height and width of both "DNS cache evictions:" elements in the left column are identical, and they are properly aligned in Safari. So I think this bug happens because the height and width of Do you know how to get the
I think this doesn't work, because the text can't overlap the shadow. |
I think is a really small thing and happens only in a specific place, in a specific browser, and it's not distorting the text or making difficult to read. We can live with that, at lest for now. |
I clicked in the wrong button. It is reopened. |
Alright. If this doesn't get fixed in the next few releases of Safari, I can look into it again. |
I'm testing the LCARS theme modifications and found a big difference in the font size. |
d225748
to
c71e022
Compare
Sorry about that - it's fixed now. |
Signed-off-by: Iksas <Iksas@users.noreply.github.com>
c71e022
to
867fb48
Compare
The https://github.com/pi-hole/AdminLTE/blob/867fb48902f99d10dda76c861b22e0506cdbfc6b/style/themes/lcars.css#L344-L345 |
@rdwebdesign do you have feedback on the changes? |
I think your changes are OK. |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released/53529/1 |
By submitting this pull request, I confirm the following:
git rebase
)git commit --signoff
)What does this PR aim to accomplish?:
This PR decreases the resource usage of various CSS animations in all themes.
The effects of this PR are described in more detail in this comment: #2021 (comment)
Additionally, this PR fixes a small layout bug mentioned in #2098.
How does this PR accomplish the above?:
Pseudo elements are added to the animated elements, so that their
opacity
property can be animated instead of the actual colors.Note that, after this PR, the text of the pseudo element used for the
lookatme
animation (the red flashing text) is defined by alookatme-text
attribute in the HTML. This attribute needs to be manually updated every time the text changes, for example:https://github.com/pi-hole/AdminLTE/blob/a5291a1909e53bd7f66a3114ed4790d19b8ac557/scripts/pi-hole/js/settings.js#L218-L221
On top of that, the frame rate has been limited to 10fps for most animations. This doesn't seem to affect the quality of the animations, since only slow color changes without movement are taking place.
There are two exceptions: The frame rate of the
letters
animation in the LCARS theme has not been limited, because limiting it somehow worsens its efficiency. The frame rate of thefire
animation in the LCARS theme has not been limited because limiting it breaks the animation.What documentation changes (if any) are needed to support this PR?:
none