Freigeben über


Trivia: Animated GIF Timing

Every now and again, someone reports that Internet Explorer is "slow" when rendering an animated GIF file. Typically, they'll load a lengthy animation in Firefox and IE and note that it runs much more quickly in Firefox. Similarly, Chrome and Safari are "slow" while Opera is "fast." Conversely, there are bug reports against Mozilla complaining that they're rendering "too fast" and should render the image more slowly.

What's going on here? Legacy compatibility with ancient versions of Netscape. An animated GIF specifies its own frame duration internally, but some of the original tools specified extremely low frame-durations (e.g. 0ms) knowing that Netscape would render the image no faster than about 10 frames per second. Therefore, if IE encounters a GIF file with a frame duration of 50ms or fewer (20fps), it will delay the animation to 100ms (10fps).

A sample image (a 2.7MB GIF mislabeled as a JPG) was reported by someone in the community and can be found here.

-Eric

Update: IE10 Consumer Preview increases the supported frame-rate; frames may be shown with a delay as little as 20ms. If the server specifies a lower delay, the animation is delayed to 100ms for legacy compatibility.

Comments

  • Anonymous
    June 07, 2010
    So an animated gif with frame durations of 51ms with be fine, but once its hits below that, frames are dragged way down to every 100ms? Why not just maintain the floor at 50ms?

  • Anonymous
    June 07, 2010
    Luckily no one has used an animated GIF since the fall of GeoCities and this has become a non-issue?

  • Anonymous
    June 08, 2010
    @Paul: The exact rationale is lost to the sands of time, but I'd imagine the explanation is that it was found (over a decade ago) that the "bad" tools would generate values below 50ms (expecting to get 10fps), and the "good" ones would generate values above 50ms. Hence, as an accommodation for "bad" tools, any value less than 50ms was demoted to the "compatible" 100ms value. @Stephen: It's fair to say that animated GIFs are far less common than they once were, although they're still commonly used for progress spinners and the like.

  • Anonymous
    June 14, 2010
    @Paul Irish: FWIW, the GIF spec specifies times in 1/100ths of a second, so 51ms is not possible to use as a GIF frame timing, 60ms is the closest available that's greater than 50.

  • Anonymous
    June 17, 2010
    You posted: "if IE encounters a GIF file with a frame duration of 50 or fewer milliseconds (20fps), it will delay the animation to 100ms (10fps). " Does this apply to all versions of IE ? I wish to know if the information is sufficiently reliable to keep in English Wikipedia.

  • Anonymous
    June 18, 2010
    Caleb: This is true for IE5 and later at the very least, but the code probably went in for IE1 or IE2.

  • Anonymous
    June 21, 2010
    We should just put an end to this madness and converge GIF rendering behavior.  :)

  • Anonymous
    July 07, 2010
    Not sure if this behavior is still applyable for IE9 PP3, though.

  • Anonymous
    July 07, 2010
    @FremyCompany: IE's behavior here remains unchanged in the latest Platform Preview Build.

  • Anonymous
    March 21, 2011
    What about the case when it runs normally but slows down when zoomed and shows weird artifacts? With this GIF (upload.wikimedia.org/.../Prince_of_Persia_%281989_video_game%29_IBM_PC_Version_gameplay.gif), you see weird artifacts (ghosts of previous frames) and the performance is blocky when zoomed.

  • Anonymous
    March 22, 2011
    @AniGIF: I don't see any performance issue when zoomed, and this may depend on your graphics hardware. As for the artifacts, yes, this is a known low-pri issue which we're tracking with a bug #.

  • Anonymous
    February 18, 2012
    also shows the "ghost(s)" while negatively zoomed. (60%, 40%, etc.)

  • Anonymous
    December 26, 2012
    Another longstanding GIF bug: GIFs configured with a loop count of 1 always play twice in IE: bugzilla.mozilla.org/show_bug.cgi

  • Anonymous
    May 22, 2013
    See nullsleep.tumblr.com/.../animated-gif-minimum-frame-delay-browser-compatibility for a survey of animated GIF timings across browsers.

  • Anonymous
    September 25, 2014
    Here's a complaint that IE11 incorrectly delays the first frame of the animation: connect.microsoft.com/.../981223