mirror of
https://github.com/felixrieseberg/windows95.git
synced 2026-05-09 00:24:09 +00:00
Wait for v86 emulator-loaded before restoring state (#367)
The 500ms setTimeout raced against v86's async wasm/BIOS/hda load. When loading exceeded 500ms (cold cache, Gatekeeper scan on packaged apps), restore_state ran on an uninitialized CPU, threw, was silently caught, and the VM cold-booted from default-state.bin instead of resuming the user's session.
This commit is contained in:
@@ -482,17 +482,16 @@ export class Emulator extends React.Component<{}, EmulatorState> {
|
||||
|
||||
ipcRenderer.send(IPC_COMMANDS.MACHINE_STARTED);
|
||||
|
||||
// Restore state. We can't do this right away
|
||||
// and randomly chose 500ms as the appropriate
|
||||
// wait time (lol)
|
||||
setTimeout(async () => {
|
||||
// Wait for v86 to finish loading wasm/bios/hda before restoring — calling
|
||||
// restore_state on an uninitialized cpu throws and we'd silently cold-boot.
|
||||
window["emulator"].add_listener("emulator-loaded", async () => {
|
||||
if (!this.state.isBootingFresh) {
|
||||
await this.restoreState();
|
||||
}
|
||||
|
||||
this.state.emulator.run();
|
||||
this.state.emulator.screen_set_scale(this.state.scale);
|
||||
}, 500);
|
||||
window["emulator"].run();
|
||||
window["emulator"].screen_set_scale(this.state.scale);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user