Loops such as for() or while() are fun, but they can get stuck if a condition that is supposed to break the loop never happens. Browser freezes in the limbo of infinity, computer fans start running like launching into the space!
Here is a while loop example:
var index = 0;
while(index<10){
//..your code here
//..that forgets to increment "index"
}
And a self-calling function:
function myFunction(){
  //..your code here
  myFunction();
}
We provide three features to prevent losing your progress due to these loops.
- Loop protection feature will inject some code to track your loops behind the scenes when you run your sketch, and it will stop it if a loop takes more than 5 seconds. When it does, you will see a warning in the console as below and you will be dropped back to your code to fix the issue. 
 β- This feature is enabled by default in the sketch settings but you may want to disable it if it causes problems with your sketch. Or, you can add "//noprotect" to the loop line in your code to tell it not to track a particular loop. - while(index<10){ //noprotect
 //..your code here
 }
- We also save the latest state of your code in your browser cache. In cases that loop protection doesn't catch an infinite loop (e.g. self-calling functions) and your browser kills the tab, simply refresh the page and our editor will recover the latest state and let you know. 
 β
- In any case, you can always access the code directly with "#code": 
 - Simply copy the URL of your sketch,
 - Open a new browser tab
 - Paste the URL and add "#code" to the end of the URL (e.g. https://www.openprocessing.org/sketch/71625#code)
 Our editor will skip running your sketch and it will directly drop you into the code to fix the issue.


