mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibWeb: Don't run HTMLImageElement timer when there is no animation
Before this change, we would wake up on every event loop iteration to drive animations in single-frame images. This was a complete waste of time and caused 100% CPU usage on our main GitHub repo page. With this change, CPU usage is ~1% when idle on the same page. :^)
This commit is contained in:
parent
7121539576
commit
ead742886b
Notes:
sideshowbarker
2024-07-17 01:21:02 +09:00
Author: https://github.com/awesomekling
Commit: ead742886b
Pull-request: https://github.com/SerenityOS/serenity/pull/23606
1 changed files with 7 additions and 1 deletions
|
@ -838,7 +838,13 @@ void HTMLImageElement::handle_failed_fetch()
|
|||
void HTMLImageElement::restart_the_animation()
|
||||
{
|
||||
m_current_frame_index = 0;
|
||||
m_animation_timer->start();
|
||||
|
||||
auto image_data = m_current_request->image_data();
|
||||
if (image_data && image_data->frame_count() > 1) {
|
||||
m_animation_timer->start();
|
||||
} else {
|
||||
m_animation_timer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#update-the-source-set
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue