Open RetiredWizard opened 4 months ago
I don't have time to set this up and test it but just for background GIF_playFrame
will return 1 for good more frames, 0 for good no more frames, or -1 for an error.
But quickly looking I'm not 100% sure the code will work exactly or you may get 0 at times.
Based on the fact you could re-save the GIF and that version works maybe a type of GIF the library does not handle and poor error handling in OnDiskGif
(oops). Exposing GIF_Reset
may also have some value in case of errors.
Thanks! This info will be helpful when I get a chance to take another look.
CircuitPython version
Code/REPL
Behavior
I have run across some animated gifs that either have a noticeable pause at the end of the animation before restarting or just run a single time when displayed by CircuitPython. In both cases the gifs play normally on my desktop computer.
I haven't been able to construct an animated gif that behaves this way and in fact, if I load the gifs in question into GIMP and re-export them they no longer have the issue on CircuitPython, which is obviously a simple workaround.
Here is an example:
Description
I originally thought the issue was that there were extra frames at the end of the animation that were flagged as unused/inactive and CircuitPython wasn't properly discarding so I looked at OnDiskGif.c to see if I could trigger the restart of the animation, before figuring that out I did try simply restarting the animation on a failed frame display and that seemed to fix the broken gifs. The change I made is:
Additional information
Now that I've discovered that the gifs can be easily repaired I'm not really concerned about this issue but I figured someone that understood more about the OnDiskGif code might see an obvious error in the logic that was accounting for the issue. If not, this issue can certainly be closed as the workaround is an easy fix.