Local variables are not persisted.
It creates that illusion.
Activities and other service calls are really proxies, whose calls are recorded
Input to a workflow is also recorded.
When a workflow is recovered, it instantiates the Workflow object first and then calls the workflow method passing the input as parameter ( It has stored the input in history )
Each time it hits a proxy, it checks the history to see if this call has already been made. If the call has been made, then it is bypassed. This goes on till it hits a proxy that has not been called yet, at which point workflow is “resumed”
This is called ‘Event Sourcing’ Pattern
A side effect is that, if in the beginning of the workflow, you have a CPU intense part, when the workflow is resumed, the CPU intense part will be played again although you have already done that before the crash.