2) user starts a computation that hangs, of a long running computation that they want to abort (probably so that they can tweak their code and try again)
- Expectation: the user wants to be able to bail out on an evaluation in progress without losing the work they've done so far (their global variables).
- Jupyter parity: at least with the python kernels, jupyter can easily interrupt evaluation without losing the global environment b/c python support "KeyboardInterrupt". This may or may not be supported for all kernels, I don't know.
- current solution: if the notebook hangs, you have to reload the whole page. Work in progress is lost -- minimally the global environment, but possibly code edits as well.
[aside: It should go without saying that anything that results in people losing work instantly disqualifies a product from being desirable. So I'll plant this as an MVP Criteria Flag: even in the worst case, iodide must make work recoverable, and should do so with minimal friction.
https://github.com/iodide-project/iodide/issues/503 is a step on this path, but not enough]
Those are the two main user needs that i have in mind around this. What am I missing?
## mitigation strategies
A) using other threads -- we may be able to solve some of this by putting computation in something other than the main content thread.
A.1) something with workers. this does not look promising based on current research. but workers are non-blocking (story 1), and can be killed (story 2)
A.2) something with extensions? i think that web extensions run in a separate thread from page content (but i haven't found a reference on that so i'm not 100% sure). if this is true, maybe there is some way of having the react/redux app live in an extension and do the app-level dom manipulation while the evaluation happens in the main content thread (or vice versa). something like this could potentially solve story 1 if the UI manipulation is on a different thread than the computation. It's unclear if this would allow for interrupt (story 2), but we might be able to simulate that with some combination of something like this and the ideas below.
B) without using other threads -- if we cannot come up with a good way of putting UI and Science computation in actually different threads -- we may at least be able to come up with mitigation strategies that make the worst case scenarios less bad.
B.1) So if we can't address story (1) by default, what can we do to make the experience less annoying. some ideas:
B.1.1) We can have better (i.e.: any) UI around running computations -- something that let's a user know that the they cannot interact with the NB because a big computation is running.
B.1.2) Some better UI around that allows heavy computation to be put into web workers. This forces a lot more complexity onto the user (and presumably adds complexity to the app too), but it might be worth it for some use cases
B.2) a few things we can do to make the experience of reloading a hung notebook less terrible:
B.2.2) Perhaps we can also stash user-defined variables in local storage and make it available when restoring autosaves (this might be tough with functions). As a subset of this, we could store variables that will be "frozen" for export (though of course we haven't worked out how freezing will work yet...)
B.2.3) We could implement the ideas above with some kind of webextension that has an "interrupt computation" button that behind the scenes just reloads the page, restores the latest autosave, and injects the user-defined variables back into the environment (or something along those lines)
Those are my ideas so far, but I know there must be other things we can do. Please jump in and let's brainstorm more ideas, and also discuss advantages/disadvantages of each.
-brendan