Error: Multiple infinite loops detected. Stopping execution. at undefined:2:33088 _ how do I resolve this?

<!let img;
let cnv;
function preload() {
img = loadImage(‘assets/IMG_0299_2.jpg’);
}
//only run once
function setup() {
cnv = createCanvas(img.width, img.height);
let newCanvasX = (windowWidth - img.width)/2;
let newCanvasY = (windowHeight- img.height)/2;
cnv.position(newCanvasX, newCanvasY);
//access the pixel information of the image
for(let col = 0; col< img.width; col+=2){
for (let row =0; row<img.height;row+=2) {
let xPos =col;
let yPos =row;
let c = img.get(xPos,yPos);
push();
translate(xPos, yPos);
rotate(radians(random(360)))
noFill();
stroke(color(c))
strokeWeight(random(2));
point(xPos, yPos);
strokeWeight(random(4));
//curve(x1, y1, x2, y2, x3, y3, x4, y4 )
curve(xPos, yPos, sin(xPos) * random(60), cos(xPos) * sin(xPos) * random (40), random(10), random(10), cos(yPos) * sin(yPos) * random(100), cos(xPos) * sin(xPos) * 50)
pop();

function keyPressed(){
if (key === ‘s’){
saveCanvas(“portrait.jpg”);
}
}
}
}
}–

If you go to the settings for your sketch and scroll to the bottom, you can turn loop protection off.

Hello @willdknyc,

Welcome to the forum.

Please read:
Welcome to the Processing Foundation Discourse

There is a useful guide in there: Guidelines - Asking Questions

You should also share the version of p5.js that you are using; I got different errors with the latest p5.js 2.x version.

Your code is not runnable as is and I had to simplify it to run without an image.

Once simplified the canvas was blank (all one color) and this worked to get different colors (replaces image for testing):

      //let c = get(xPos, yPos);
      let c = color(random(255), random(255), random(255));

I had to correct an error with keyPressed() first (commented it out entirely for starters) and then I saw this with version p5.js 1.11.13 (Default):

And code works with the Loop Protection Off:

:)

Thanks for the solution.