You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[p5.js 2.0+ Bug Report]: The last three saveCanvas() reference examples throw an error and save nothing #9381
Open the saveCanvas() reference page and copy any of the last three examples into a sketch running p5.js 2.x.
Run it.
No file is downloaded and the console shows TypeError: filename.includes is not a function.
The first three examples (saveCanvas(), saveCanvas('myCanvas.jpg'), saveCanvas('myCanvas', 'jpg')) work fine.
Possible cause
In 2.x, createCanvas() returns a p5.Renderer and createGraphics() returns a p5.Graphics and neither is a p5.Element anymore. The checks at the start of saveCanvas() in src/image/image.js only look for an HTMLCanvasElement, a p5.Element or a p5.Framebuffer so the renderer is treated as the filename.
save() in src/io/files.js already handles this case with args[0] instanceof Renderer || args[0] instanceof Graphics. When I added the same branch to saveCanvas() using args[0].canvas, all three examples worked locally.
Bug confirmed, thanks for reporting @Akshats-git. if you want to file a PR please go ahead, otherwise please comment that htis can be opened for volunteers!
Activity
ksen0 commentedon Nov 8, 2026
Bug confirmed, thanks for reporting @Akshats-git. if you want to file a PR please go ahead, otherwise please comment that htis can be opened for volunteers!
Akshats-git commentedon Nov 8, 2026
Thanks @ksen0 . I will open a PR for this soon.