Remove minimum frame delay from GIF89a files.

UNCONFIRMED
Unassigned

Status

()

P3
normal
UNCONFIRMED
4 months ago
4 months ago

People

(Reporter: robert.ancell, Unassigned, NeedInfo)

Tracking

63 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

4 months ago
Posted image animation-multi-image-zero-delay.gif (obsolete) —
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0

Steps to reproduce:

The GIF89a format is designed to composite multiple images together. This is useful to do things like:
- Use more than 256 colours by switching color tables while rendering
- Efficiently transmit animation by only sending small updates between frames

From section 8 (The Decoder) in the specification (https://www.w3.org/Graphics/GIF/spec-gif89a.txt): "The decoder has the following primary responsibilities." "Process each graphic in the Data Stream in sequence, without delays other than those specified in the control information.

Firefox adds a minimum frame delay of 0.1 second (bug 125137) between images in a GIF file, which causes short visual glitches which an image is being assembled. The reasons given seem to be:
- Handling broken GIFs in the wild
- Matching the behaviour of other browsers

It was proposed some years ago (bug 890743) to not do this delay when the GIF doesn't loop, but then that was reverted in bug 1126330.

I've attached a test case that shows this.


Actual results:

The animation shows 7 frames, with red pixels flashing while rendering.


Expected results:

The animation should show only four frames, with no red visible (total time 2s).
(Reporter)

Updated

4 months ago
Component: Untriaged → ImageLib
Product: Firefox → Core
(Reporter)

Comment 1

4 months ago
Analysing the two cases in the bugs that stopped the frame delay being removed:

1. http://gassend.net/spaceelevator/breaks/break0.gif

This is a GIF87a file, and that specification did not have the Graphic Control Extension (which sets the delay). So I think it's reasonable to have a default delay in these files.

2. https://i.imgur.com/krYrx02.gif

This is a GIF89a file which has Graphic Control Extensions but they're all set to zero. This is probably a case where a heuristic could be applied if necessary.

Are there any other cases that anyone knows of where GIFs are broken?
(Reporter)

Comment 2

4 months ago
See related bug 1511290 about the delays being applied to multiple images. Both these bugs have come out of developing a GIF test suite (https://github.com/robert-ancell/pygif/tree/master/test-suite).
(Reporter)

Comment 3

4 months ago
This is a larger image showing the issue
(Reporter)

Comment 4

4 months ago
The above image was generated with:

#!/usr/bin/python

import gif

width = 40
height = 40

writer = gif.Writer (open ('animate-min-delay.gif', 'wb'))
writer.write_header ()
writer.write_screen_descriptor (2*width, 2*height, has_color_table = True, depth = 2)
writer.write_color_table ([(0, 0, 0), (255, 255, 255), (255, 0, 0), (0, 255, 0)], 2)
writer.write_netscape_extension (loop_count = 0)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 50)
writer.write_image (2*width, 2*height, 2, ([ 1 ] * width + [ 0 ] * width) * height + [ 0 ] * (2 * width) * height)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 0)
writer.write_image (width, height, 2, [ 2 ] * width * height, width, 0)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 50)
writer.write_image (width, height, 2, [ 1 ] * width * height, width, 0)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 0)
writer.write_image (width, height, 2, [ 2 ] * width * height, width, height)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 50)
writer.write_image (width, height, 2, [ 1 ] * width * height, width, height)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 0)
writer.write_image (width, height, 2, [ 2 ] * width * height, 0, height)
writer.write_graphic_control_extension (gif.DisposalMethod.KEEP, delay_time = 50)
writer.write_image (width, height, 2, [ 1 ] * width * height, 0, height)
writer.write_trailer ()
(Reporter)

Updated

4 months ago
Attachment #9028868 - Attachment is obsolete: true
(Reporter)

Comment 5

4 months ago
(Reporter)

Updated

4 months ago
Attachment #9028870 - Attachment description: animate-min-delay.gif → Animation that flashes red - the red parts should have zero delay.
Flags: needinfo?(aosmond)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.