1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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)*/
}
|