Hi is it possible to make snapshot of runtime, serelize it to file and
then restore runtime on other client. I understand that snapshotting
have a lot of pitfalls. But for now I want to implement simpliest
case. My target is wasm, main loop is executed by requestAnimation
frame.

So stack always same:

request animation frame -> loop function -> create/resotre memory ->
actual programm implementation

The first code in loop function is to restore/save heap, like this:

static void em_main_loop(void) {
    if (doHeapOperation()) {
        return;
    }

    // actual programm implementation
}

As heapOperation I use this:

Module.heapOperation = function() {
    delete Module.heapOperation;
    var buffer = new ArrayBuffer(Module.HEAPU8.byteLength);
    window.heapCopy = new Uint8Array(buffer);
    window.heapCopy.set(Module.HEAPU8);
    console.log("INFO: heapCopy created");

    function restore() {
        Module.heapOperation = function() {
            delete Module.heapOperation;
            Module.HEAPU8.set(window.heapCopy);
            console.log("INFO: heapCopy loaded");
        }
    };

    setTimeout(restore, 1000);
}

So, I just saving all wasm memory, and then restore it after 1 sec.
And this code works in 50% cases, sometimes program is start as 1
second before, but other time it continue with unpredictable
behaviour.

Because we paused / resume with same memory and same stack I assume
that everything should works. But, in reality it does not. Is
emscripten also save some state in javascript? What I am missing.
Assume that my program did not use FS, GPU, SOUNDS and pure native (no
EM_ASM inside), is this technique should works?

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVHBPUGg7%3DbWSTT0b_%2BKy5TAv6LvHk2Kc7Un3udY6%2BGTLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to