Ever notice how gifs take forever to load on Safari?

Tue, Mar 23, 2010

News

Once a staple of the web, animated gifs have for the most part been rendered obsolete by a number of other technologies used to relay video content. But they do still exist, and every once in a while you run into an animated gif that you just gotta see. And if you happen to be running Safari, you’ve undoubtedly noticed that gifs load frustratingly, if not painfully, slow on Apple’s built-in web browser.  But why is that?

A recent thread on Reddit tackled that very question:

It’s just a difference in how WebKit handles the animation. WebKit waits for the entire gif to load before it starts animating the image, whereas other web browsers will show you the frames as they come in. I think it does this so that it can cache the entire animation in quicktime and play it back smoother with less cpu drag.

A long time ago I found a plist setting that let you turn that off so that it started playing immediately, but alas my google-fu is weak.

Reddit user revrii adds:

It’s a bug in Mac OS X’s Core Graphics. Instead of just using prior frame as a reference in rendering, it just re-render the whole file on every frame. The problem did not exist in Chrome because they use a different decoder for GIF animations.

A bug indeed. Webkit.org has a thread on the very problem over here.

The solution?

Reddit user pudquick writes:

Are you sure it’s not because you run a WebKit nightly?

http://trac.webkit.org/changeset/43807

Anyways, when you get a chance, dump your WebKit-related plists (they can be in Safari’s plists too) with:

plutil -convert xml1 -o - ~/Library/Preferences/com.apple.Safari.plist
plutil -convert xml1 -o - ~/Library/Preferences/com.apple.WebFoundation.plist

and look for anything listed in:

http://www.opensource.apple.com/source/WebKit/WebKit-6531.9/mac/WebView/WebPreferenceKeysPrivate.h

As an aside: From what I read, people who use the WebKit nightlies don’t have this problem.

We’ll give it a try soon and fire up some animated gifs and see how Safari responds. We’ll keep ya updated.

  Share

, , ,

1 Comments For This Post

  1. Tom Says:

    or just update your safari in Software Update. The version that was released a couple of weeks ago fixes the issue.

eXTReMe Tracker