Why an Optimized GIF Leaves Trails: Check Frame Disposal
Use a three-frame particle fixture to separate leftover pixels from baked trails and decoder differences.


An optimized GIF is smaller, but a moving particle now leaves dots behind. An encoder can replace full frames with smaller rectangles. The decoder then needs the right instruction for what to do with the previous rectangle.
Make a three-frame reference
On a 96 by 48 dark canvas, draw a single bright dot at the left, center and right in successive frames. Redraw the full background in each reference frame. Use the same frame duration and keep a copy of the complete frames. Compare the middle frame and the first frame of the second loop in the optimized and reference versions.
Inspect the composited frames
If a small rectangle draws only the new dot and the preceding frame is left in place, the old dot may still be visible. Restore to background applies to the preceding frame's own rectangle, not the entire canvas. Restore to previous returns the covered area to its earlier state. A transparent pixel does not paint over an already composited pixel. Decode to complete displayed frames before comparing them against the reference.
Check playback before counting bytes
If both outputs trail, inspect the source art. If only one player trails, compare another decoder and check the loop boundary. If the optimized copy alone is wrong, keep the original and test explicit disposal or a full-frame export. Use the asset compression tool to check available formats, and make sure your GIF test retains animation; a still image is not a valid result.
Ready to try "Why an Optimized GIF Leaves Trails: Check Frame Disposal"?
Use our online tools to apply this tutorial to your indie game project right away.
