Long running programs (which occur more often when using Python than Javascript) may give the impression that nothing is happening. Previously, I had tried to implement a UI feature where some window would be shown prior to evaluating the user's code but, due to the single threaded nature of Javascript and the way I had implemented the function, the window was never shown. However, there is a way around this and it might be worth revisiting this issue.
When clicking on the "run" button, instead of doing something like
// not the real code
function run() {
eval(code);
playback_frames();
}
it might be useful to do the following instead:
function _run() {
eval(code);
hide_visual();
playback_frames();
}
function run() {
show_visual();
setTimeout(_run, 1); // delay thread so that UI update can take place
}
Edit
An alternative might be to have eval(code) be done, somehow, in a webworker, and have it use postMessage every time a new frame is recorded, so that the frame display is updated.
Long running programs (which occur more often when using Python than Javascript) may give the impression that nothing is happening. Previously, I had tried to implement a UI feature where some window would be shown prior to evaluating the user's code but, due to the single threaded nature of Javascript and the way I had implemented the function, the window was never shown. However, there is a way around this and it might be worth revisiting this issue.
When clicking on the "run" button, instead of doing something like
it might be useful to do the following instead:
Edit
An alternative might be to have
eval(code)
be done, somehow, in a webworker, and have it usepostMessage
every time a new frame is recorded, so that the frame display is updated.