mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
Add safari mobile "workaround" for freezing
This commit is contained in:
parent
94816efefa
commit
569db3dac7
1 changed files with 31 additions and 0 deletions
|
@ -1093,6 +1093,10 @@ class EmulatorJS {
|
||||||
if (this.debug) console.warn("Could not fullscreen on load");
|
if (this.debug) console.warn("Could not fullscreen on load");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.isSafari && this.isMobile) {
|
||||||
|
//Safari is --- funny
|
||||||
|
this.checkStarted();
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.warn("failed to start game", e);
|
console.warn("failed to start game", e);
|
||||||
this.textElem.innerText = this.localization("Failed to start game");
|
this.textElem.innerText = this.localization("Failed to start game");
|
||||||
|
@ -1101,6 +1105,33 @@ class EmulatorJS {
|
||||||
}
|
}
|
||||||
this.callEvent("start");
|
this.callEvent("start");
|
||||||
}
|
}
|
||||||
|
checkStarted() {
|
||||||
|
(async() => {
|
||||||
|
let sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||||||
|
let state = "suspended";
|
||||||
|
let popup;
|
||||||
|
while (state === "suspended") {
|
||||||
|
if (!window.AL) return;
|
||||||
|
window.AL.currentCtx.sources.forEach(ctx => {
|
||||||
|
state = ctx.gain.context.state;
|
||||||
|
});
|
||||||
|
if (state !== "suspended") break;
|
||||||
|
if (!popup) {
|
||||||
|
popup = this.createPopup("", {});
|
||||||
|
const button = this.createElement("button");
|
||||||
|
button.innerText = "Click to resume Emulator";
|
||||||
|
button.classList.add("ejs_menu_button");
|
||||||
|
button.style.width = "25%";
|
||||||
|
button.style.height = "25%";
|
||||||
|
popup.appendChild(button);
|
||||||
|
popup.style["text-align"] = "center";
|
||||||
|
popup.style["font-size"] = "28px";
|
||||||
|
}
|
||||||
|
await sleep(10);
|
||||||
|
}
|
||||||
|
if (popup) this.closePopup();
|
||||||
|
})();
|
||||||
|
}
|
||||||
bindListeners() {
|
bindListeners() {
|
||||||
this.createContextMenu();
|
this.createContextMenu();
|
||||||
this.createBottomMenuBar();
|
this.createBottomMenuBar();
|
||||||
|
|
Loading…
Reference in a new issue