mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Behind a new config flag, emulatorjs.auto_save_sync (default false), the EmulatorJS player uploads the in-game save (.srm) to the server on EmulatorJS' own "System Save interval" tick, without Save & Quit. EmulatorJS already runs that timer (default 300 s) and its gameManager.saveSaveFiles() fires a "saveSaveFiles" event carrying the SRAM bytes, but nothing listens to it, so today an in-game save reaches the server only from Save & Quit or the Export Save File button (#4201). This subscribes to that event from Player.vue and uploads through the existing saveSave() when the SRAM hash is unchanged since the previous tick (a save the core is still writing is never uploaded — the corruption the earlier automatic upload was removed for, #2349) and differs from the last upload (an idle session uploads nothing). The tracker is seeded from the SRAM the core holds after the server save is applied, so a launch never uploads the server's own file back, and the subscription is turned off before Save & Quit, Quit and unmount. The bytes EmulatorJS hands out are views onto the emulator heap, a SharedArrayBuffer on threaded cores; they are copied into a plain ArrayBuffer before hashing or uploading. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>