I have a function that gets called with setInterval()
like this:
canvasInterval = setInterval(updateCGoL, (1000/this.frameRate)|0);
I am allowing the user to specify the frames per second (with limitations, only non-NaN values after parseInt()
as Math.max(Math.min(
user input , 30), 1)
). Even if it runs at 30 frames per second I am pretty sure it is completing its work before the next frame. My questions though are:
- What happens if it does not finish its work within the amount of time I gave it?
- Is there a way to test if it did not finish its work before the next frame if this is a problem?
Edit: (Copy / pasted from comments) If the limit of my function is 20 frames per second (to compute) but I have setInterval running at 30 frames per second will it instead run at 20? (As opposed to two functions running at the same time)