Thanks a lot. Now everything seems working. Changes that helps me: 1. Do save/restore operation only if EmterpreterAsync.state === 0 (normal state) 2. Reset some variables that depends on current time
вт, 14 мая 2019 г. в 22:56, Alon Zakai <[email protected]>: > > The EmterpreterAsync JS object does have a few fields, yes. I think they only > matter during an async event though. > > To debug this kind of thing, the DETERMINISTIC option may be useful. It makes > all timing and random numbers deterministic, which for many programs (without > user input, and single-threaded) means it is deterministic, so you can re-run > the same reloaded program to debug it. > > On Tue, May 14, 2019 at 3:56 AM Александр Гурьянов <[email protected]> > wrote: >> >> Thanks for feedback. Now I am saving and restoring all wasm mutable >> globals. But seems it does not help, I still have unstable behaviour. >> I forgot to say that I use emterpeter too, can it produce additional >> problem for save/restore wasm state? >> >> вс, 12 мая 2019 г. в 22:31, Liam Wilson <[email protected]>: >> > >> > A couple of years ago was playing around with something similar with >> > Emscripten in asm.js mode. I was able to snapshot/restore program state by >> > saving the contents of the heap to another array, and also saving >> > STACKTOP. I also had to replace _malloc and _free as there seemed to be >> > some internal state in there too. >> > >> > Code is here >> > https://github.com/cosinusoidally/emscripten_experiments/blob/master/jpeg_decoding/time_travel_test.js >> > >> > Thanks >> > Liam Wilson >> > >> > >> > On Friday, May 10, 2019 at 12:33:05 PM UTC+1, caiiiycuk wrote: >> >> >> >> 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/ca1ab65c-d418-4ba6-89b8-8f2fc08501f1%40googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. >> >> -- >> 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%3DVFttict2uVoLWTTdeScUFjeu8FFhFif%3DJSm%3Djvd4%3DFdkA%40mail.gmail.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > 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/CAEX4NpTm0pkGNvRuzH42cNUzEPnpCEkrb7xfk_ArW3uaefPKEQ%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- 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%3DVFg-s7zUrAc-Z%2BKNR2P4chPYFRpfg6AVfJkW2mz73zgyw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
