processing / processing/p5.js-web-editor

Image loading doesn't work with for loops

Open
#1,836 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
JavaScript
Stars
1.7k
Forks
1.7k
Avg merge
3d 4h
Merged PRs (30d)
8

Description

Nature of issue?
  • Found a bug

I'm running into something odd where when I try to load my images in a for loop in the preload function, the images can't resolve. It seems like the file paths are being changed in some way so that p5 can't find the images.

If I try to load the images by typing them all out by hand, then they load just fine.

Here's a sketch showing what happens: https://editor.p5js.org/aferriss/sketches/RyE5Z91iC

I'm wondering if this is related to this issue https://github.com/processing/p5.js-web-editor/issues/771

Details about the bug:
  • Web browser and version: Chrome 89.0.4
  • Operating System: Mac OSX
  • Steps to reproduce this bug:

Try to load images dynamically during a for loop in the preload function

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

Open the linked p5.js Editor sketch and reproduce the image-loading failure with paths generated in a preload for loop, then compare it with manually listed paths. Trace how the editor handles those paths and consider the issue complete when dynamically loaded images resolve as reliably as manually listed images.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.