p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

loadImage can brake the whole sketch

Open clankill3r opened this issue 3 years ago • 4 comments

If you take the default example and add this:

function preload() {
	loadImage("banner_512x128.mp4", (img)=> {

	},
	(err)=> {
		console.log("mp4 you idiot!");
	});
}

Then you get, as expected "mp4 you idiot!" and "p5.js says: It looks like there was a problem loading your image. Try checki....".

I know this is plain stupid, but it also means a corrupt image can break a whole sketch.

clankill3r avatar Feb 03 '21 14:02 clankill3r

The preload counter is not decremented in the case of an error. It can perhaps be made so that if the error callback is provided the sketch continue to run. I'm just not sure how this can be considered a breaking change or not.

limzykenneth avatar Feb 24 '21 22:02 limzykenneth

Even if it would be a breaking change, it would be the right step forward. Also, if it would be, all it would do is make sketches that don't run at the moment run right?

clankill3r avatar Feb 25 '21 07:02 clankill3r

Breaking change is more about managing expectations, specifically expectation that the same semantic code that is written for one version works in the same way in another version. Though that does not mean this change is a breaking change, I'm just not sure whether it should be counted as one or not.

I'm a bit overloaded at the moment so cannot spend the time to think through cases where this change could have an effect and what kind of effect, so will have to leave this for later or for someone else to have a look.

limzykenneth avatar Mar 01 '21 22:03 limzykenneth

@limzykenneth I would like to work on this, could you please let me know where I should start looking?

Swapnil-2001 avatar Mar 14 '21 11:03 Swapnil-2001