-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
saveGif() crashes when duration <= 0 (empty frame list path) #8710
Copy link
Copy link
Open
Labels
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.
Reactions are currently unavailable