p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Image loading doesn't work with for loops

Open aferriss opened this issue 4 years ago • 5 comments

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

aferriss avatar Apr 07 '21 23:04 aferriss

I ran into similar issues. Might be related. It seems to work if you wait ~5 minutes after uploading the file. (I didn't get any errors when I ran your sketch). Might be related to my issue: https://github.com/processing/p5.js-web-editor/issues/1738

da091005 avatar Apr 08 '21 02:04 da091005

@da091005 Strange! It's working fine for me now as well. I feel that still it shouldn't take 5 minutes for you to be able to use your images, or if it does can we provide the user with some information on when their image data will be available?

aferriss avatar Apr 08 '21 18:04 aferriss

Yea I think it’s a VERY strange bug. If you access the files directly it works immediately. But if you try to use a variable to access the files it takes like 5 minutes.

da091005 avatar Apr 08 '21 23:04 da091005

I still experience this issue a lot as well during live sessions with my classes. I too have found that waiting a bit resolves the issue initially. I kept forgetting to come back and reopen #771 but I agree it may be related somehow.

slowizzm avatar Apr 22 '21 15:04 slowizzm