Commit 484121c1 authored by mrowe@apple.com's avatar mrowe@apple.com

Bug 35065: Delay between page loading and animated GIF playing

<http://webkit.org/b/35065> / <rdar://problem/7109548>

Reviewed by Darin Adler.

BitmapImage::startAnimation was adding the current frame duration to the desired start time
of the frame for every time it was called.  If the function then bailed out due to not having
sufficient data to render the frame, this would lead to the desired start time of the frame
being pushed out multiple times.  On an animated GIF that took mulitple seconds to load this
could happen many times for a single frame, resulting in the start time of the second frame
of the animation being pushed out by as much as five seconds.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::startAnimation): Change the order of the code slightly so that the
desired start time is only updated after determining that we have sufficient data to handle
the next frame.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ea001ce4
2010-02-17 Mark Rowe <mrowe@apple.com>
Reviewed by Darin Adler.
Bug 35065: Delay between page loading and animated GIF playing
<http://webkit.org/b/35065> / <rdar://problem/7109548>
BitmapImage::startAnimation was adding the current frame duration to the desired start time
of the frame for every time it was called. If the function then bailed out due to not having
sufficient data to render the frame, this would lead to the desired start time of the frame
being pushed out multiple times. On an animated GIF that took mulitple seconds to load this
could happen many times for a single frame, resulting in the start time of the second frame
of the animation being pushed out by as much as five seconds.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::startAnimation): Change the order of the code slightly so that the
desired start time is only updated after determining that we have sufficient data to handle
the next frame.
2010-02-17 Stephan Aßmus <superstippi@gmx.de>
Reviewed by Eric Seidel.
......
......@@ -266,6 +266,18 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary)
if (m_frameTimer || !shouldAnimate() || frameCount() <= 1)
return;
// Don't advance the animation to an incomplete frame.
size_t nextFrame = (m_currentFrame + 1) % frameCount();
if (!m_allDataReceived && !frameIsCompleteAtIndex(nextFrame))
return;
// Don't advance past the last frame if we haven't decoded the whole image
// yet and our repetition count is potentially unset. The repetition count
// in a GIF can potentially come after all the rest of the image data, so
// wait on it.
if (!m_allDataReceived && repetitionCount(false) == cAnimationLoopOnce && m_currentFrame >= (frameCount() - 1))
return;
// Determine time for next frame to start. By ignoring paint and timer lag
// in this calculation, we make the animation appear to run at its desired
// rate regardless of how fast it's being repainted.
......@@ -284,18 +296,6 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary)
m_desiredFrameStartTime = time + currentDuration;
}
// Don't advance the animation to an incomplete frame.
size_t nextFrame = (m_currentFrame + 1) % frameCount();
if (!m_allDataReceived && !frameIsCompleteAtIndex(nextFrame))
return;
// Don't advance past the last frame if we haven't decoded the whole image
// yet and our repetition count is potentially unset. The repetition count
// in a GIF can potentially come after all the rest of the image data, so
// wait on it.
if (!m_allDataReceived && repetitionCount(false) == cAnimationLoopOnce && m_currentFrame >= (frameCount() - 1))
return;
// The image may load more slowly than it's supposed to animate, so that by
// the time we reach the end of the first repetition, we're well behind.
// Clamp the desired frame start time in this case, so that we don't skip
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment