Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/image/loading_displaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,20 @@ function _createGif(
failureCallback,
finishCallback
) {
const gifReader = new omggif.GifReader(arrayBuffer);
let gifReader;
try {
gifReader = new omggif.GifReader(arrayBuffer);
} catch (e) {
p5._friendlyFileLoadError(8, pImg.src);
if (typeof failureCallback === 'function') {
failureCallback(e);
} else {
console.error(e);
}
finishCallback();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for consistency sake with other loading functions we don't call finishCallback() here which will resolve the preload even in the case of an error.

return;
}

pImg.width = pImg.canvas.width = gifReader.width;
pImg.height = pImg.canvas.height = gifReader.height;
const frames = [];
Expand Down