p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

editor crashing with infinite loops, and edge cases - update `loop-protect` to use `jsbin/loop-protect`

Open Xendergo opened this issue 7 years ago • 9 comments

Nature of issue?

  • [x] Found a bug
  • [ ] Existing feature enhancement
  • [ ] New feature request

Details about the bug: When auto-refresh is enabled and I'm typing a for loop, the editor crashes.

  • Web browser and version: Google Chrome | 69.0.3497.92 (Official Build) (64-bit) (cohort: Stable)
  • Operating System: Windows 10

Xendergo avatar Sep 20 '18 20:09 Xendergo

thanks for reporting! there's a library included in this project to prevent infinite loops from crashing the editor, which should prevent this. however, i noticed that

for (var i = 0; ;) {

}

is caught and stopped by the loop-protect code, but

for (let i = 0; ; ) {

}

is not caught and handled by the loop protect code.

catarak avatar Sep 20 '18 20:09 catarak

i was looking at the loop-protect library and it seems like the version that i made the fork from (jsbin/loop-protect) has updated the project a lot, and i think it would make sense for this project to switch from the fork i made to the jsbin library. i also just tested the two for loops on jsbin, and it seems to catch the infinite loop for both of them, so this gives me confidence that this change would fix this bug.

catarak avatar Sep 20 '18 21:09 catarak

i started to work on this, following the instructions here, but keep getting the following error from Babel: cannot read property 'registerPlugin' of undefined. for some reason when i do import Babel from '@babel/standalone';, Babel is still undefined.

catarak avatar Oct 03 '18 21:10 catarak

switching this to high priority—seems like it's causing a lot of bugs and frustration.

catarak avatar Oct 25 '18 17:10 catarak

@catarak can you help me with this. I think we have to make changes in the previewEntry.js file?

siddhant1 avatar Mar 17 '19 08:03 siddhant1

I have made some progress but not able to catch the infinite loop , I have asked the developer of this library to help me with it . I will send a PR soon to close this.

siddhant1 avatar Mar 17 '19 18:03 siddhant1

I have made some progress and its running with var and while loops but for (let) loops are still not working

siddhant1 avatar Mar 18 '19 13:03 siddhant1

Not sure if this is happening but I feel that we need to transpile down to es5 and then createa the transformed code , I converted it to use jsbin/loop-protect but it still stucks on for(let) loop #947

siddhant1 avatar Mar 19 '19 07:03 siddhant1

Though this thread is old, I wanted to upvote this significant problem in which an accidental infinite loop essentially leaves us doomed to have to close the window (and lose all saved work, though issue #1405 is separately addressing that).

What would be great is if there was a way for user to interrupt the script, even when stuck in an infinite loop. There is still a visible play/stop button in the editor GUI so it would be great if the thread that is running the sketch could have some intentionally yielding so the GUI has a chance to detect the stop button and stop the sketch thread from running. That would be ideal way to stop the loop while not having to close the window and lose code or crash the entire browser.

goldwasser avatar Oct 17 '24 04:10 goldwasser