saveGif() crashes when duration <= 0 (empty frame list path)
Nobody has claimed this yet.
- 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
- p5.strands
- WebGL
- DevOps, Build process, Unit testing
- Internationalization (i18n)
- Friendly Errors
- Other (specify if possible)
p5.js version
main
Web browser and version
Chrome (latest stable)
Operating system
Windows 11 (should be OS-independent)
Steps to reproduce this
Steps:
- Create any sketch.
- Call saveGif('test', 0) (or negative duration) in setup() or from a key handler.
- Check console.
snippet:
function setup() {
createCanvas(100, 100);
background(220);
circle(50, 50, 30);
// Repro: zero duration
saveGif('test', 0);
// also repros with negatives, e.g. saveGif('test', -1);
}
Console error:
TypeError: Cannot read properties of undefined (reading 'length')
Expected behavior
saveGif() should reject invalid duration early (e.g. duration must be > 0)
or gracefully handle zero captured frames without crashing.
Actual behavior
duration <= 0 leads to zero captured frames, then palette generation path assumes frames[0] exists and crashes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the saveGif() entry point and trace the zero-duration path through captured frames and palette generation, especially the frames[0] access mentioned in the report. Reproduce with saveGif('test', 0) and a negative duration in setup(); done means invalid durations no longer produce the reported TypeError and the chosen behavior is covered by the relevant test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100