processing / processing/p5.js

noLoop() not honored by saveGif()

Open
#7,354 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Core Bug
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

1.11.0

Web browser and version

130.0.6723.92

Operating system

macOS

Steps to reproduce this
Steps:
  1. Run the snippet below
Snippet:
function setup() {
  createCanvas(400, 400);
  saveGif('mySketch', 5, { units: "frames" });
  noLoop();
}

function draw() {
  background(220);
  console.log("draw");
}

It'd be great to have the ability to create animated Gifs from graphics that aren't possible to create real-time (e.g. because each frame requires a web API call, which takes multiple seconds to complete). p5's redraw() function would be great for this to use (i.e. this invokes draw whenever a frame is ready to be added to the animation). Unfortunately, the current implementation of saveGif() does not seem to honor noLoop() - as the draw function is called periodically regardless.

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

Run the provided sketch and compare the behavior of saveGif() with noLoop(). Trace the saveGif() and noLoop() entry points to understand why draw() continues periodically, then verify that a GIF can wait for redraw() when frames require asynchronous work. Confirm the existing five-frame example still works and no longer ignores noLoop().

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.