processing / processing/p5.js

[p5.js 2.0 Bug Report]: saveGif generates black frames at start of gif

Open
#8,123 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Core p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.0.5

Web browser and version

Safari (20622.1.22.118.4), Chrome 141.0.7390.55

Operating system

macOS Sequoia 15.7.1

Steps to reproduce this
Steps:
  1. Add saveGif to default template (also fails if other elements added)
  2. Set p5.js version to 2.0 or higher
  3. Run and create gif

Gifs created with version 2.0 or higher insert 2 black frames at the beginning of each gif. The two black frames come before the draw loop runs. For example, in the below code/attached gif, it contains 2 black frames and then numbered frames 1-58.

The same code run with p5 1.x will not produce these two black frames and will contain 60 frames from the draw loop. When the below code is run in 1.11.10, it creates numbered frames 1-60.

A similar issue was reported in https://github.com/processing/p5.js/issues/6080 and fixed (https://github.com/processing/p5.js/pull/6081). It appears this same fixed code was carried through to 2.0.x

Snippet:

function setup() {
  createCanvas(400, 400);
  saveGif("sketch", 1)
  textSize(48)
}

function draw() {
  background(220);
  text(frameCount, width/2, height/2)
}

Image
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the saveGif implementation and compare its behavior in p5.js 2.0.5 with 1.11.10, also reviewing the related issue #6080 and fix in pull request #6081. Reproduce the supplied sketch and verify that the generated GIF starts with the draw-loop frames, without two black frames, and contains the expected 60 frames.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.