Skip to content

preload() hangs on loadImage #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
slowizzm opened this issue Aug 31, 2018 · 20 comments
Open

preload() hangs on loadImage #674

slowizzm opened this issue Aug 31, 2018 · 20 comments

Comments

@slowizzm
Copy link

preload() hangs when trying to loadImage(), never loads.

Google Chrome | 68.0.3440.106 (Official Build) (64-bit) (cohort: Stable)
Revision | 1c32c539ce0065a41cb79da7bfcd2c71af1afe62-refs/branch-heads/3440@{#794}
OS | Windows

@catarak
Copy link
Member

catarak commented Aug 31, 2018

i'm not able to reproduce this! the following sketch works for me: https://editor.p5js.org/cassie/sketches/SJlIk0WUPX

can you add a link to your sketch? thanks!

@slowizzm
Copy link
Author

Weird, it is working for me now as well, your sketch and mine.

No longer an issue.

thanks

@catarak catarak closed this as completed Aug 31, 2018
@mberndtgen
Copy link

mberndtgen commented Aug 31, 2018

Sorry for re-opening this, but I was able to reproduce this. In preload(), I'm loading 15 images into an array like so:

  for (var i = 0; i < numOfImages; i++) {
    imgs[i] = loadImage("images/" + i + "_image.png");
  }

and draw wasn't able to show them. Only after modifying my code and 'forcing' them to display (like so:

function draw() {
  image(imgs[0], 0, 0);
}

, doing this for each picture, one by one, made me eventually display them as intended. After this procedure my original code worked as expected. Felt a bit like filling a cache. Definitely weird and maybe worth a look.

@catarak
Copy link
Member

catarak commented Aug 31, 2018

@mberndtgen can you post a link to your sketch? i'm not quite sure i get what the different cases are.

this could have to do with programmatically-generated image names, they're loaded in a different way than if they're a simple string (i.e. loadImage("images/0_image.png"); vs your for loop).

@catarak catarak reopened this Aug 31, 2018
@mberndtgen
Copy link

@mberndtgen
Copy link

Strange, huh? :-) This code worked without problems in the alpha version of the editor.

@catarak
Copy link
Member

catarak commented Sep 4, 2018

@mberndtgen i was playing with your sketch and i couldn't figure out what was wrong because of all of the other stuff going on in that project (which is really cool btw!). would you mind making an example that only shows the thing that appears to not be working?

@mberndtgen
Copy link

Yeah, sure! (And thanks! This is my homework for a course on Kadenze.) Here is the essence of what it takes (at least for me) to reproduce the error:
https://editor.p5js.org/mberndtgen/sketches/ByBKxP2vQ

It was even a bit stranger than expected: I've cloned this project from the original one (via File > Duplicate) and modified it. I've changed the png's in the images folder, too (but they still have the names of the original project: 0_image.png, 1_image.png etc.) When I run this code then imgs[0] is displayed as an image of my original project, while the same image that was loaded directly (not into an array) is displayed correctly. See here:

strange-p5editor-behavior

Background: image from array, green thingy: correct image. Both were loaded as 0_image.png. This is different from my first experience when no image of the array was displayed at all, but I guess this could have the same cause.

@slowizzm
Copy link
Author

slowizzm commented Sep 6, 2018

preload() loadImage() array is working for me ....

https://editor.p5js.org/slow_izzm/sketches/BJnX6QJ_X

@catarak
Copy link
Member

catarak commented Sep 7, 2018

@mberndtgen this is what I see:
screen shot 2018-09-07 at 12 51 57 pm
so I think for me it's... working? I'm feeling very confused about what exactly the issue you're seeing is. I am also using Chrome.

@mberndtgen
Copy link

Oh weirdness! Now it's working on my side, too! Can't reproduce the error any longer. You better close this issue until this changes again. :-) Thanks a lot for your effort, though, I really appreciate!
(Adventure's almost finished, btw.)

@catarak
Copy link
Member

catarak commented Sep 7, 2018

maybe it's a caching thing, or a network connection thing. i'll close this for now!

@catarak catarak closed this as completed Sep 7, 2018
@slowizzm
Copy link
Author

slowizzm commented Oct 24, 2018

@catarak
This may need to be re-opened.

I have no issues with preload() in safari or firefox, but on Chrome 70 on macOS (High Sierra) preloads hangs on loadImage and never loads.

https://editor.p5js.org/slow_izzm/sketches/r1OcQ45om

@catarak
Copy link
Member

catarak commented Oct 24, 2018

@slowizzm thanks! i'll try updating chrome and see if i can reproduce.

@catarak catarak reopened this Oct 24, 2018
@slowizzm
Copy link
Author

@slowizzm thanks! i'll try updating chrome and see if i can reproduce.

thank you ... looks like you fixed it, it's working as expected now.

@catarak
Copy link
Member

catarak commented Oct 25, 2018

i think there's sometimes an issue loading assets from S3, which comes up unpredictably.

@catarak
Copy link
Member

catarak commented Feb 9, 2021

This issue comes up intermittently but I've never been able to pinpoint the exactly cause. Sometimes S3 will just send back a CORS issue, and then moments later it won't. Not sure! I'm going to close this but feel free to open a new issue if it comes up again.

@catarak catarak closed this as completed Feb 9, 2021
@selazbin-s
Copy link

first link posted (https://editor.p5js.org/cassie/sketches/SJlIk0WUPX) is not working

@eyaler
Copy link

eyaler commented May 13, 2024

i am seeing loadImage() failing specifically in preload() on macOS. same sketch works on windows. sketch works on macOS if loadImage is moved into setup(). should i open a new issue or could this be reopened?

@raclim
Copy link
Collaborator

raclim commented May 13, 2024

Thanks for reporting this @eyaler! We can reopen this issue!

@raclim raclim reopened this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants