4 ms·
IMO a better, though more complex, solution would be to keep the frame delays as specified in the GIF, but to disable GIF looping if the sum of all frame delays
by wzdd 5y ago
IMO a better, though more complex, solution would be to keep the frame delays as specified in the GIF, but to disable GIF looping if the sum of all frame delays was less than 10 ms. That way you get the one good use case (>256 colour gifs) but malicious or broken GIFs with 0 frame delays don't hang your machine. This is complicated by the fact that browsers (used to?) display the first frame of a GIF before the complete animation was loaded. But you could handle that easily enough by making this decision at the time of first loop rather than at initial GIF load.
(Fortunately, this is all largely irrelevant nowadays.)