Skip to content

Commit 026ea70

Browse files
authored
Merge pull request #6081 from davepagurek/fix/gif-setup
Fix black first frame when rendering gifs in setup
2 parents 6d70c7a + 9d7cde2 commit 026ea70

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/image/loading_displaying.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ p5.prototype.saveGif = async function(
317317
// stop the loop since we are going to manually redraw
318318
this.noLoop();
319319

320+
// Defer execution until the rest of the call stack finishes, allowing the
321+
// rest of `setup` to be called (and, importantly, canvases hidden in setup
322+
// to be unhidden.)
323+
//
324+
// Waiting on this empty promise means we'll continue as soon as setup
325+
// finishes without waiting for another frame.
326+
await Promise.resolve();
327+
320328
while (frameIterator < totalNumberOfFrames) {
321329
/*
322330
we draw the next frame. this is important, since

0 commit comments

Comments
 (0)