Skip to content

Commit 26ad19d

Browse files
committed
Add additional cross origin isolation message
1 parent 379ff66 commit 26ad19d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

index.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
max-width: 8rem;
4040
}
4141

42-
.not-hosted-msg {
42+
.not-hosted-msg,
43+
.no-coi-msg {
4344
text-align: center;
4445
position: absolute;
4546

@@ -87,6 +88,7 @@
8788

8889
const { protocol } = window.location;
8990
const isHosted = protocol !== "file:";
91+
const isCOI = crossOriginIsolated ?? false;
9092
let raylibJs = undefined;
9193

9294
function startRaylib(selectedWasm){
@@ -96,6 +98,21 @@
9698
raylibExampleSelect.value = selectedWasm;
9799

98100
if (isHosted) {
101+
if (!isCOI) {
102+
window.addEventListener("load", () => {
103+
document.body.innerHTML = `
104+
<div class="no-coi-msg">
105+
<div class="important">
106+
<p>Unfortunately, due to security restrictions, <code>SharedArrayBuffer</code> cannot be used.</p>
107+
<p>Please navigate to this location using a web server that has the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements">required headers set</a>.</p>
108+
<p>If you have Python 3 on your system you can just do:</p>
109+
</div>
110+
<code>$ python3 ./server.py 6969</code>
111+
</div>
112+
`;
113+
});
114+
return;
115+
}
99116
if (raylibJs !== undefined) {
100117
raylibJs.stop();
101118
}
@@ -113,7 +130,7 @@
113130
<p>Please navigate to this location using a web server.</p>
114131
<p>If you have Python 3 on your system you can just do:</p>
115132
</div>
116-
<code>$ python3 -m http.server 6969</code>
133+
<code>$ python3 ./server.py 6969</code>
117134
</div>
118135
`;
119136
});

0 commit comments

Comments
 (0)