[Webkit-unassigned] [Bug 239272] The first frame of an animation GIF is sometimes skipped on GTKWebKit and WinCairo

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 12 20:55:40 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=239272

--- Comment #1 from Yuki Sekiguchi <yuki.sekiguchi at access-company.com> ---
The following patch fixed this bug on GTKWebKit.
```
diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp
index 1a0ba366f423..253f4b787ba6 100644
--- a/Source/WebCore/platform/graphics/BitmapImage.cpp
+++ b/Source/WebCore/platform/graphics/BitmapImage.cpp
@@ -480,8 +480,11 @@ BitmapImage::StartAnimationStatus BitmapImage::internalStartAnimation()
     MonotonicTime time = MonotonicTime::now();

     // Handle initial state.
-    if (!m_desiredFrameStartTime)
+    if (!m_desiredFrameStartTime) {
+        if (!frameIsCompleteAtIndex(m_currentFrame))
+            return StartAnimationStatus::IncompleteData;
         m_desiredFrameStartTime = time;
+    }

     // Setting 'm_desiredFrameStartTime' to 'time' means we are late; otherwise we are early.
     m_desiredFrameStartTime = std::max(time, m_desiredFrameStartTime + Seconds { frameDurationAtIndex(m_currentFrame) });
```

I have no idea how to test this using LayoutTest, so I don't create a patch now. Any advice is very welcome!

Description:
BitmapImage::internalStartAnimation() starts the animation timer if the current frame is *decoding* and all data is received or next frame is decoded. Therefore, even if the current frame isn't decoded, the animation timer starts. If the current frame isn't decoded, BitmapImage::draw() skips to draw the current frame.  Then, if the first frame in test.gif isn't decoded during its frame duration, the first frame isn't shown.

This patch waits for the first frame if animation haven't started.

Safari doesn't start the animation timer because the following condition is true:
```
    // Don't advance the animation to an incomplete frame.
    if (!m_source->isAllDataReceived() && !frameIsCompleteAtIndex(nextFrame)) {
        printf("BitmapImage::internalStartAnimation() return IncompleteData nextFrame\n");
        return StartAnimationStatus::IncompleteData;
    }
```

I guess that since Safari and GTKWebKit uses different decoder, only Safari becomes true the above condition.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220413/41f50d07/attachment.htm>


More information about the webkit-unassigned mailing list