aboutsummaryrefslogtreecommitdiff
path: root/crash
diff options
context:
space:
mode:
Diffstat (limited to 'crash')
-rw-r--r--crash/artwork.jpgbin0 -> 83347 bytes
-rw-r--r--crash/client.js114
-rw-r--r--crash/crash.html72
-rw-r--r--crash/wrapper.js41
4 files changed, 227 insertions, 0 deletions
diff --git a/crash/artwork.jpg b/crash/artwork.jpg
new file mode 100644
index 0000000..a999d22
--- /dev/null
+++ b/crash/artwork.jpg
Binary files differ
diff --git a/crash/client.js b/crash/client.js
new file mode 100644
index 0000000..d5ea355
--- /dev/null
+++ b/crash/client.js
@@ -0,0 +1,114 @@
+if (native) {
+ function crash(error) {
+ try {
+ require('@electron/remote').getCurrentWindow().hide();
+ } catch (e) {}
+ id = new Date().toISOString();
+
+ try {
+ global.pkg = require('./package.json');
+ } catch (e) {
+ console.warn(e);
+ global.pkg = require('../package.json');
+
+ }
+
+ report = "\n";
+ report += "Kartik Crash Report\n\nPlease send this to the developers so they can fix the problem and deploy a patch to all players.\n\nStack Trace:\n"
+ error.stack.split("\n").forEach((line) => {
+ report += " " + line + "\n";
+ })
+ report += "\n\nSystem Information:\n"
+ report += " " + "Kartik"+require('@electron/remote').getCurrentWindow().channel + "(" + pkg.name + ") " +pkg.version + " [" + pkg.serial + "]\n";
+
+ report += " " + require('os').type() + " (" + require('os').version() + ", " + require('os').arch() +") version " + require('os').release() + "\n";
+ cores = require('os').cpus()
+ if (cores.length > 1) {
+ report += " " + cores.length + " processors";
+ } else {
+ report += " " + cores.length + " processor";
+ }
+ report += "\n\nKartik Components:\n";
+ Object.keys(process.versions).forEach((e) => {
+
+ v = process.versions[e];
+ report += " " + e + "@" + v + "\n";
+ })
+
+ require('fs').writeFileSync(require('os').userInfo().homedir + "/.kartik/crashes/" + id + ".txt", report);
+ if (error.message !== "Invalid display" && error.message !== "Out of memory") {
+
+ fetch("https://kartik.hopto.org/telemetry/report/?report=" + btoa(report.replaceAll(require('os').userInfo().username, "<information removed>")))
+
+ .then(() => {
+ if (require('os').platform() === "win32") {
+ require('child_process').execSync("runtime\\kartik-crash.bat");
+ } else if (require('os').platform() === "darwin") {
+ require('child_process').execSync("./runtime/kartik-crash-mac.sh");
+ } else {
+ require('child_process').execSync("./runtime/kartik-crash.sh");
+ }
+ require('@electron/remote').getCurrentWindow().destroy();
+
+ window.close();
+ require('@electron/remote').getCurrentWindow().close();
+ })
+ .catch(() => {
+ if (require('os').platform() === "win32") {
+ require('child_process').execSync("runtime\\kartik-crash.bat");
+ } else if (require('os').platform() === "darwin") {
+
+ require('child_process').execSync("./runtime/kartik-crash-mac.sh");
+ } else {
+ require('child_process').execSync("./runtime/kartik-crash.sh");
+ }
+ require('@electron/remote').getCurrentWindow().destroy();
+ window.close();
+ require('@electron/remote').getCurrentWindow().close();
+ })
+ } else {
+ if (require('os').platform() === "win32") {
+ require('child_process').execSync("runtime\\kartik-crash.bat");
+ } else if (require('os').platform() === "darwin") {
+ require('child_process').execSync("./runtime/kartik-crash-mac.sh");
+ } else {
+ require('child_process').execSync("./runtime/kartik-crash.sh");
+ }
+
+ require('@electron/remote').getCurrentWindow().destroy();
+ window.close();
+ require('@electron/remote').getCurrentWindow().close();
+ }
+ }
+
+ window.onerror = (_a, _b, _c, _d, error) => {
+ if (typeof error != "undefined") {
+ crash(error);
+ } else {
+ error("CrashManager", "An exception was thrown without details about it");
+ crash(new Error("Unknown error"));
+ }
+ }
+
+ process.on('uncaughtException', (error) => {
+ if (typeof error != "undefined") {
+ crash(error);
+ } else {
+ error("CrashManager", "An exception was thrown without details about it");
+ crash(new Error("Unknown error"));
+ }
+ })
+
+ /*setInterval(() => {
+ try {
+ if (document.body.clientWidth >= (screen.width - 50) || document.body.clientHeight >= (screen.height - 50) || require('@electron/remote').getCurrentWindow().pwidth >= (screen.width - 50) || require('@electron/remote').getCurrentWindow().pheight >= (screen.height - 50) || require('@electron/remote').getCurrentWindow().scale < 0.9) {
+
+ if (!location.href.includes("credits.html")) {
+ error("CrashManager", "Invalid display, crashing");
+ crash(new Error("Invalid display"));
+ // TODO: Instead reset the size and restart
+ }
+ }
+ } catch (e) {}
+ }, 2000)*/
+}
diff --git a/crash/crash.html b/crash/crash.html
new file mode 100644
index 0000000..5b922aa
--- /dev/null
+++ b/crash/crash.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script src="../lang/loader.js"></script>
+ <meta charset="UTF-8">
+ <script>document.title = lang.crash.title;</script>
+ <link rel="stylesheet" href="../views/common/fonts.css">
+ <style>
+
+ * {
+ font-family: -apple-system, sans-serif;
+ cursor: default !important;
+ font-family: "Comfortaa", -apple-system, sans-serif !important;
+ }
+
+ button {
+ border: 1px solid #00b763;
+ padding: 10px 20px;
+ border-radius: 999px;
+ background: #fff;
+ color: black;
+ outline: none;
+ }
+
+ button:hover {
+ color: white;
+ border: 1px solid #007b42;
+ background: #00b763;
+ }
+
+ button:active {
+ color: white;
+ border: 1px solid #00502b;
+ background: #007b42;
+ }
+
+ </style>
+</head>
+<body style="display:grid;grid-template-columns: 1fr 1fr;height:100%;width:100%;margin:0;overflow:hidden;">
+ <div>
+ <img src="./artwork.jpg" style="height: 100vh;">
+ </div>
+ <div style="padding:8px;">
+ <h2><script>document.write(lang.crash.head);</script></h2>
+ <p><script>document.write(lang.crash.intro);</script></p>
+ <p><script>
+ document.write(lang.crash.report[0]);
+ if (require('os').platform() === "win32") {
+ document.write(require('os').userInfo().homedir + "\\.kartik\\pilot\\crashes");
+ } else {
+ document.write(require('os').userInfo().homedir + "/.kartik/crashes");
+ }
+ document.write(lang.crash.report[1]);
+ </script></p>
+ <p><button onclick="restart();"><script>document.write(lang.crash.close);</script></button> <button onclick="resetrestart();"><script>document.write(lang.crash.reset);</script></button></p>
+ </div>
+
+ <script>
+ function restart() {
+ window.close();
+ require('@electron/remote').getCurrentWindow().hide();
+ require('@electron/remote').getCurrentWindow().destroy();
+ require('@electron/remote').getCurrentWindow().close();
+ }
+ function resetrestart() {
+ require('fs').rmdirSync(require('os').userInfo().homedir + "/.kartik/config", {recursive:true});
+ window.close();
+ require('@electron/remote').getCurrentWindow().close();
+ }
+ </script>
+</body>
+</html>
diff --git a/crash/wrapper.js b/crash/wrapper.js
new file mode 100644
index 0000000..ba5a8b9
--- /dev/null
+++ b/crash/wrapper.js
@@ -0,0 +1,41 @@
+const { app, BrowserWindow } = require('electron')
+
+if (require('fs').existsSync(require('os').userInfo().homedir + "/.kartik/config/lang.txt")) {
+ lp = require('fs').readFileSync(require('os').userInfo().homedir + "/.kartik/config/lang.txt").toString();
+}
+
+function createWindow () {
+ const win = new BrowserWindow({
+ width: 800,
+ height: 375,
+ resizeable: false,
+ resizable: false,
+ maximizable: false,
+ bgColor: "#ffffff",
+ title: "Kartik",
+ webPreferences: {
+ nodeIntegration: true,
+ contextIsolation: false,
+ enableRemoteModule: true,
+ webviewTag: true
+ }
+ })
+
+ win.lp = lp;
+ win.loadFile('crash.html')
+ win.setMenu(null);
+}
+
+app.whenReady().then(createWindow)
+
+app.on('window-all-closed', () => {
+ if (process.platform !== 'darwin') {
+ app.quit()
+ }
+})
+
+app.on('activate', () => {
+ if (BrowserWindow.getAllWindows().length === 0) {
+ createWindow()
+ }
+}) \ No newline at end of file