Jump to content

Wacky animated gif behavior


L.Adlon

Recommended Posts

Just wondering if anyone here can shed some light on this...

 

I have a spash page that has a swf file and an animated gif on it. Normally, it works just great, but sometimes I get some odd behavior.

 

The gif will load, play maybe a couple of frames, freeze, then after a bit, it'll play a few more frames, freeze, then sometimes stay frozen, and sometimes finally play fully (and loop).

 

My understanding is that if a gif is loaded, and there's some issue, it'll just sit on the first frame. Is this random behavior I'm sometimes seeing it struggling to load in time? Would it not wait until all the frames are loaded before playing, or does it just plough through, and pause if it is still loading the frames it's reached?

 

Any simple thing I can do? I'm rusty on the whole preloader thing, if that's what I should be doing with the gif.

 

It's not a big deal, but would be nice if I could eliminate that occassional glitch. Doesn't always happen, though.

 

 

I tried a few suggested non-javascript preload methods, but they don't seem to either work properly (display code on page) or just don't help the matter (gif still randomly pauses).

 

One clue... for some reason, hovering the mouse over the hyperlinks on the page seems to suddenly make the gifs animate again.

 

Would the swf loading it's frames in the meantime possibly cause pauses in the animated gif playback?

 

 

(Yep, hovering over a hyperlink definitely fixes it... It's like the gif needs to be woken up or something!)

 

I found another thread about this issue, although I'm not following the solutions:

 

http://www.webdeveloper.com/forum/showthread.php?90647-RESOLVED-ie-animated-gif-freeze-til-page-loads

Edited by L.Adlon
Link to comment
Share on other sites

I tried adding the gif as a <div> background image, rather than an <img> (...setting the height/width, and not to repeat). The performance seems a bit better. So far, if anything, it just has a micropause after a 1/2 second, then plays fine.

 

Is adding an image using the <div> background-image:url(image/splashtitle.gif) method completely supported and safe, or is it still better do just use an <img> for an image?

 

Why would hovering over an unrelated hyperlink on the page make the 'stuck' gif play again?

Link to comment
Share on other sites

The situation seemed to be improved a bit by me making the frame rate of the gif a bit less (from 15fps to 12fps), reducing the colour from 64 to 32, and the overall number of frames.

 

Sometimes it plays flawlessly... other times, a micro stutter at the start, and then fine. So, a bit better. Still curious what the deal is, and if it could still be improved on.

Link to comment
Share on other sites

GIF images do that because they try to play as they are loading. If your internet isn't really fast they'll stop at a frame while the next one is getting loaded.

Link to comment
Share on other sites

Ya, initially, that's what it seemed like... the GIF playback pausing as the SWF hit a (relatively) large frame to download.... but, what I don't get is why, in some instances, the GIF would completely stop... AND why it could be immediately restarted by hovering over a completely unrelated hyperlink.

 

My only guess is that the act of triggering an a:hover causes the screen to refresh... or HTML to 'recalculate'... or something?

 

BTW, these tests are all offline... so no downloading. I'll be uploading the site in the next few days, so I can see how it performs with actual downloading.

 

From what I'm reading elsewhere, this (or something similar) is a known issue with GIFs... playing for a second or so, then stopping (...aside from the cases where it is doing that because it's set to only play once).

 

It's really odd...and somewhat random (...or, more accurately, is probably affected by other items, and therefore sometimes happens, and sometimes doesn't, based on the activity of that other item, or something like that).

 

Well, it's not bad now. I've got a preloader (which I really hope is okay), and I reduced the total frames and FPS of the GIF. At this point, it either plays for 1 sec, pauses for 1/2 sec, then plays fine... or just plays fine from the beginning. So, if I can't improve on it further, it's not a show-stopper.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...