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);
|
ipcRenderer.send(IPC_COMMANDS.MACHINE_STARTED);
|
||||||
|
|
||||||
// Restore state. We can't do this right away
|
// Wait for v86 to finish loading wasm/bios/hda before restoring — calling
|
||||||
// and randomly chose 500ms as the appropriate
|
// restore_state on an uninitialized cpu throws and we'd silently cold-boot.
|
||||||
// wait time (lol)
|
window["emulator"].add_listener("emulator-loaded", async () => {
|
||||||
setTimeout(async () => {
|
|
||||||
if (!this.state.isBootingFresh) {
|
if (!this.state.isBootingFresh) {
|
||||||
await this.restoreState();
|
await this.restoreState();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.emulator.run();
|
window["emulator"].run();
|
||||||
this.state.emulator.screen_set_scale(this.state.scale);
|
window["emulator"].screen_set_scale(this.state.scale);
|
||||||
}, 500);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user