Subject: Re: bug#40685: 28.0.50; eww browser chews up 100% cpu when displaying looping gif animations

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 29 Jul 2020 08:24:24 +0200

Francis Meetze <[email-masked]> writes:

> When opening a web page in the Emacs browser that contains infinite looping gif animations Emacs starts spinning up 100% CPU even after the emacs browser is closed.  Emacs has to be completely shut down to reduce the CPU usuage.
>
> If the 100% CPU process is allowed to run its course, it eventually stops after several minutes with the message, "Stopping animation; animation possibly too big". 

Yeah, that triggers when it's taken more than two seconds to get the
next frame.  Emacs can be totally unusable for a long time, though,
because we may get a new frame faster than that, but leave no CPU for
the rest of Emacs.

Lowering the limit seems like an obvious solution, but that will make
many animations stop if Emacs is occasionally busy with something else.

So that simplistic test is error-prone and doesn't really help that much
with the problem.

I wonder whether a different heuristic could be written...  not
something that stops the animation if a single frame arrives too late,
but averaged over several frames.  That is, if frames consistently
arrive (way) too late, then it's probably using all the CPU, and should
stop.  Hm...  it doesn't seem to hard two write something like that, I
think?  I'll give it a go.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no