Skip to content

Commit

Permalink
Add additional cross origin isolation message
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPieper committed Feb 21, 2024
1 parent 379ff66 commit 26ad19d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
max-width: 8rem;
}

.not-hosted-msg {
.not-hosted-msg,
.no-coi-msg {
text-align: center;
position: absolute;

Expand Down Expand Up @@ -87,6 +88,7 @@

const { protocol } = window.location;
const isHosted = protocol !== "file:";
const isCOI = crossOriginIsolated ?? false;
let raylibJs = undefined;

function startRaylib(selectedWasm){
Expand All @@ -96,6 +98,21 @@
raylibExampleSelect.value = selectedWasm;

if (isHosted) {
if (!isCOI) {
window.addEventListener("load", () => {
document.body.innerHTML = `
<div class="no-coi-msg">
<div class="important">
<p>Unfortunately, due to security restrictions, <code>SharedArrayBuffer</code> cannot be used.</p>
<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>
<p>If you have Python 3 on your system you can just do:</p>
</div>
<code>$ python3 ./server.py 6969</code>
</div>
`;
});
return;
}
if (raylibJs !== undefined) {
raylibJs.stop();
}
Expand All @@ -113,7 +130,7 @@
<p>Please navigate to this location using a web server.</p>
<p>If you have Python 3 on your system you can just do:</p>
</div>
<code>$ python3 -m http.server 6969</code>
<code>$ python3 ./server.py 6969</code>
</div>
`;
});
Expand Down

0 comments on commit 26ad19d

Please sign in to comment.